-
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
[Compiler Bug]: value read during render does not update when using react-hook-form
.watch
API
#29144
Comments
react-hook-form
.watch
API
Thanks for filing this. If i'm understanding correctly, the issue is with the following two lines: const form = useForm({ defaultValues: { customerId: "", addressId: "" } });
const customerId = form.watch("customerId"); Where the React Compiler is applying the equivalent of the following to this code: const form = useForm({ defaultValues: { customerId: "", addressId: "" } });
const customerId = useMemo(() => form.watch("customerId"), [form]); If you do the same, and apply useMemo (without the compiler), does |
@josephsavona Thanks for the quick response.
If I apply this change manually without the compiler enabled, I still get the same result ( I can get around issue using the |
Thanks for confirming. As I noted above, React expects components to be idempotent and only update if their props, state, or context changes. It looks like the The |
Got it - thanks! Will close out then since this works as expected when using |
What kind of issue is this?
Link to repro
https://github.com/erikshestopal/react-compiler-bug
Repro steps
Reproduction steps:
bun install
bun dev
to start the dev serverWhen trying to read a value during render using
react-hook-form
's.watch
API with thebabel-plugin-react-compiler
plugin enabled, the value is not updated and the component that is supposed to be rendered conditionally never renders.How often does this bug happen?
Every time
What version of React are you using?
19.0.0-rc-3f1436cca1-20240516
The text was updated successfully, but these errors were encountered: