Closed nmn closed 5 years ago
The subscribe call thas to be in useEffect
for it to work correctly. redux-react
goes through a lot of effort to make sure parents are re-rendered first, and I'm not sure we can even do that with a hook, or that we want to. We had this same problem in Proton at first, but making our connected components resilient to being re-rendered before their parents was worth doing anyway.
Since I don't think we want to add this behavior (@gaearon recommended against it), I'm going to close this PR. Thanks, though, for bringing it up!
I'm not sure about this. This was just a quick and dirty thing that popped into my head. I will try to test if this works sometime.
But I think this should hopefully ensure that at least on the first render, a parent will subscribe to changes before the child. Things get messy if the store needs to resubscribe for some reason.