-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invoke-listeners-in-render #31
Conversation
This would seem to be problematic specifically because the point of Concurrent Mode is that existing in-progress trees can be thrown away. |
Yeah, the tree can be thrown away, but does that mean the local state (in this case the forceUpdate counts) is thrown away, which prevents re-renders? @markerikson how can we convince this approach works/fails? any ideas? |
Okay, I was able to at last reproduce the thrown-away behavior. And, by removing |
So, here's a big guess. It's natural to assume that we don't need https://github.com/facebook/react/blob/b4178af81b02dfa0e898670ce564c4649fd8947f/packages/react-reconciler/src/ReactFiberWorkLoop.js#L597 Just made a small example. |
Summary: This specific change is not tied to state usage tracking, so any react-redux hooks app can be simply tried by replacing the library. |
https://github.com/facebook/react/blob/ce883a19d845e1faf8d4e1587e7022feda66210a/packages/use-subscription/src/useSubscription.js#L51-L55 |
When I implemented #26, I assumed it's safer to invoke listeners in useLayoutEffect.
However, this leads to "de-optimize to sync mode" [1]. And, it's actually slow [2].
This changes to invoke listeners in render. There might be some cases that prevent from properly working. I would like to know such cases. Eventually someone would try it an file an issue. Will see.