Fork me on GitHub
#reagent
<
2022-03-18
>
Drew Verlee15:03:17

With a form 2 component like so

(defn outer 
  [a b c]            ;; <--- parameters
  ;;  ....
  (fn [a b c]        ;; <--- forgetting to repeat them, is a rookie mistake
    [:div
      (str a b c)]))
I assume there is problem ignoring the outer params when they aren't used in the first outer scope, like this:
(defn outer 
  [_ _ _]            ;; <--- parameters
  ;;  ....
  (fn [a b c]        ;; <--- forgetting to repeat them, is a rookie mistake
    [:div
      (str a b c)]))

p-himik15:03:29

And what would be the problem?

p-himik15:03:12

The outer fn args are used on mount. The inner fn is used when the component is updated, and it's re-rendered if the inner fn's return value is different from the previous call. In the inner fn, you might (accidentally or intentionally) create a closure over the outer fn's args. If it's accidental, then that's exactly wht that "rookie mistake" points out. But by not using the outer fn's args, you can't really do anything bad here. You just happen to not need those arguments for component initialization, and that's it.

Drew Verlee15:03:23

I can't imagine what the issue would be, beyond some macro intervention, though that seems impossible. Thanks!

👍 1