Fork me on GitHub
#reagent
<
2020-11-23
>
flowthing10:11:33

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?

p-himik11:11:12

If you have (let [x (reagent/atom value)] ...), instead of passing just x to the relevant components, pass @x along with #(reset! x %).

p-himik11:11:17

Be sure to store #(reset! x %) instead of creating it each time:

cljs.user=> (= #() #())
false

flowthing11:11:39

Right, thanks for the tip — certainly would've forgotten about that.