https://github.com/reagent-project/reagent/blob/master/doc/ReactFeatures.md#hooks says "If you need to pass RAtom state into these components, dereference them in the Reagent components and pass the value (and if needed, function to update them) as properties into the React function component." I don't quite understand what that means. Does anyone happen to have any examples handy?
If you have (let [x (reagent/atom value)] ...)
, instead of passing just x
to the relevant components, pass @x
along with #(reset! x %)
.
Ah! Thanks!
Be sure to store #(reset! x %)
instead of creating it each time:
cljs.user=> (= #() #())
false
Right, thanks for the tip — certainly would've forgotten about that.