Fork me on GitHub
#reagent
<
2021-12-23
>
Drew Verlee07:12:10

(defn child []
  [:span "World!"])

(defn parent []
  [:div {:ref ref-fn}
   "Hello, "
   [child @state]])
what does it mean for child to be called with any argument here given it doesn't have any params?

valtteri07:12:02

Effectively same as ‘(defn child [_] …)’. You pass derefed state as the first arg but the function ignores it.

valtteri07:12:01

Javascript doesn't care 🙂

valtteri07:12:23

No magic in reagent in this case either (afaik)

p-himik07:12:30

child function will be called on each state change. Doesn't matter in this case, might matter in some. I would probably consider it a code smell if something relies on this behavior.

valtteri07:12:02

Passing state there is totally unnecessary

valtteri07:12:49

If programmer had some intention there, it's suspicious

Drew Verlee07:12:20

thanks for the explanation

👌 1