-
Notifications
You must be signed in to change notification settings - Fork 50k
Description
What kind of issue is this?
- React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
- babel-plugin-react-compiler (build issue installing or using the Babel plugin)
- eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
- react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro
Repro steps
When rendering something with an expression conditionally like this {!hidden && <input value={field.state.value} onChange={(e) => field.handleChange(e.target.value)}/>}, the "memo dependencies" to trigger a rerender are hidden and field.
This is different when rendering the input without a condition like this {<input value={field.state.value} onChange={(e) => field.handleChange(e.target.value)}/>}, the "memo dependencies" are "field.handleChange" and "field.state.value".
This change of behavior can cause some unexpected issues:
- in my case, using @tanstack/form, the field property isn't reactive in itself but its subproperties are. This prevents the input from updated its value when the user types inside the input
- if field was reactive, a change inside field that is neither the value or handleChange would trigger a rerender that shouldn't be needed
This can happen with a bool && <div> or with a bool ? <div> : <div> expression
Not really sure if this is expected behavior and if it is, what is the recommended fix.
I've opened an issue over at @tanstack/form
How often does this bug happen?
Every time
What version of React are you using?
19.0.0
What version of React Compiler are you using?
1.0.0