Fork me on GitHub
#reagent
<
2020-11-27
>
jmckitrick17:11:23

In a simple reagent component using let and a local r/atom for state, what causes the component to re-render? I can’t figure out why 2 similar forms are behaving differently in this regard.

jmckitrick17:11:11

One component is working fine, the other ‘on change’ is triggering the component to re-render as if the incoming data has changed, but from what I can see, only the local r/atom should be updating with each edit.

p-himik18:11:54

Can you post the actual code?

jmckitrick20:11:14

It’s too unwieldy, but I appreciate the offer. I found wrapping the hiccup in a fn and returning that seems to have solved the issue, though. Not sure why the already working component did not need that approach.

Lu21:11:41

There’s a r/with-let function that allows you to define your ratom without needing a fn wrapping. If you define your ratom in a let of a simple reagent component, then the ratom can’t hold any useful value because it gets re-defined along with the rendering of its component.