- The long-standing problem of trying to synchronize an external synchronous state container with React's async rendering cycle
- That our existing solution for this problem requires overriding values in context for connected components
- The fact that context usage _require_ rendering a <Context.Provider> to update a value
- The fact that hooks themselves do not do any rendering
So, the solution we have for avoiding stale props only works with `connect`. It's not that the hooks themselves are problematic or have inherent gotchas, it's just that hooks don't offer the specific additional capability we would need to implement that same solution in both places.
A user just put together a _fantastic_ article that dives deeper into this specific problem, and recaps how each version of React-Redux tried to solve it [1]. Highly recommended reading if you have some time.
[0] https://react-redux.js.org/api/hooks#stale-props-and-zombie-...
[1] https://kaihao.dev/posts/Stale-props-and-zombie-children-in-...
I've encountered the issue before, but never knew the name. After bumping into it a couple of times I just changed up how I use react-redux.
Those react-redux hooks just exemplify the issues I have with hooks.
Yeah, potentially less code, but with more (and in some instances, completely unheard of) gotchas, more that the developer has to do to keep parity with not using hooks, and certain things dropped entirely.
I'm super interested in this discussion. I've been using React for years, and it's been smooth sailing. But somethings up with hooks, and I haven't been able to put it into words.