fix(react): track owners separately, mutate updaters with dispatcher - #130
Conversation
|
✅ Deploy Preview for preact-signals-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
marvinhagemeister
left a comment
There was a problem hiding this comment.
This looks great! Let's add one or few test cases that ensure that we don't regress on this in the future 👍
|
Would it be fine to settle for cases that cover the linked issues (doesn't crash in production, will consistently re-render in both production/strict-mode) or would you prefer to re-run the test suite (IDK how you'd sanely configure a testing matrix or mock/clear dependencies here)? I'll commit the first in a moment as a baseline. |
Sounds good enough to me 👍 Instead of mocking dependencies we could add a new alias to something like |
marvinhagemeister
left a comment
There was a problem hiding this comment.
This is great! Thank you for your PR 🙌
|
We'll have to trust Netlify CI in lieu of a controlled production environment. |
Add missing changeset for #130
Fixes #125
Fixes #135
Fixes #70
This PR tracks
ReactCurrentOwnerseparately fromReactCurrentDispatchersince the former is not guaranteed to be populated whenReactCurrentDispatcheris mutated. This is very evident from #125, and you can verify by running against a production build of React. Annoyingly, this behavior is different than that of a development build of React.Additionally, signals' updaters are mutated on subsequent runs since there are multiple dispatchers during the lifecycle of a component, and holding on to a stale dispatcher can break the re-rendering mechanism (it wouldn't do anything).
The changes in this PR originally came from tweaking with v1 JS output, which you can find in this gist. This is runnable if you want to copy/paste it into a Codesandbox, although ensure you're using the old JSX transform (
React.createElement) if possible for the moment.