-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
fix(react): track owners separately, mutate updaters with dispatcher #130
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
ReactCurrentOwner
separately fromReactCurrentDispatcher
since the former is not guaranteed to be populated whenReactCurrentDispatcher
is 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.