Closed grav closed 6 years ago
Yeah this won't work. This will cause bad behavior because reagent handles its own atom watching and re-rendering.
You have to add :watch-atom true explicitely if you are passing a function to defcard-rg. And this is only helpfull for top level components. What really needs to happen is we probably need to wrap the function in a react component that handles the atom listening.
But for now the function case is a bit pathological. Some more thought is needed here ...
How about solution in #100 ?
I had a problem with state-dependent components not updating when I mutated the state:
http://recordit.co/Az2hgc9gUu
I must admit I'm not fully aware of what
:watch-atom
does, but swapping it fromfalse
totrue
in thedefcard-rg
macro did the trick.http://recordit.co/jTW4C6btET
Before, I had to wrap a component like this:
but with this patch, I can inline the call to the wrapper: