-
Notifications
You must be signed in to change notification settings - Fork 47k
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
feat(compiler): Consider dispatch fn from useActionState and useFormState to be non-reactive #29758
feat(compiler): Consider dispatch fn from useActionState and useFormState to be non-reactive #29758
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
...r/src/__tests__/fixtures/compiler/useFormState-dispatch-considered-as-non-reactive.expect.md
Outdated
Show resolved
Hide resolved
...r/src/__tests__/fixtures/compiler/useFormState-dispatch-considered-as-non-reactive.expect.md
Outdated
Show resolved
Hide resolved
...compiler/src/__tests__/fixtures/compiler/useFormState-dispatch-considered-as-non-reactive.js
Outdated
Show resolved
Hide resolved
941c01a
to
9f817ae
Compare
@josephsavona Thanks for the review! I have updated the import. |
@hieudo-dev Looks like this needs a rebase and formatting of the code via Prettier. |
…tate to be non-reactive
9f817ae
to
28a6e36
Compare
Thanks for the heads up! I've updated the PR. |
Hi @josephsavona, just wanted to give you a friendly reminder that this PR should be ready for further review/merging. Feel free to let me know if you see any issues left |
I couldn't push here, so i added an updated version at #29917 which includes your commit. Thanks for the contribution! |
Updated version of #29758 removing `useFormState` since that was the previous name for `useActionState`. --------- Co-authored-by: Hieu Do <[email protected]>
Summary
Currently, the dispatch functions returned by
useActionState
anduseFormState
are considered as reactive. This will cause the compiler to miss some optimizations opportunities.This PR updates
babel-plugin-compiler-react
to tag those dispatch functions as non-reactive so they can be pruned and optimized accordingly.Addresses #29674
How did you test this change?
Manually, by running the compiler playground locally. My assumption is that non-reactive returnValues will be checked against
Symbol.for("react.memo_cache_sentinel")
in the compiled code, so this was used as the success criteria of this PR.Fixtures were added to test this as well.