[Bug v7.0.0] useField returns undefined value on initial render despite initialValues being set
Description
Hi, thanks for your work on the library!
We're encountering a blocking issue when trying to migrate to [email protected] to prepare for React 19.
Problem
When initialValues are passed to the <Form />, the corresponding fields registered via useField initially return value: undefined. This was not the case in earlier versions.
It seems that the field state is now derived via form.getFieldState() during initialization here — but this runs before the field is registered here, so the field state is not available at that moment.
As a result:
Fields render with value: undefined on the first render. Components relying on the initial value (e.g., to initialize local state or trigger effects) fail or misbehave.
Expect result:
Fields render with defined value on initialize as it was before in v6.5.9
Sandbox Link
v6.5.9 https://codesandbox.io/p/sandbox/h7lk86
Logs:
v7.0.0 https://codesandbox.io/p/sandbox/6cd2fz
Logs:
Noticed the same issue while migrating to expo 53/React 19. At first, I assumed there was something wrong with our ref usage and React 19 changes, but in the end I figured final-form might be at cause. In the end:
- We kept the changes to expo53/react 19
- Reverted to
final-form:4.20.10andreact-final-form:6.5.9 - Overrides were set for both package to use React-19 And everything seems to work fine. So there seems to be something that changed with the changes in 7.0.0, but haven't had the time to look at the code yet.
Same issue on Expo 53/React 19, had to roll back to the pre-typescript version
@chevvy What solution do you use for this?
- Overrides were set for both package to use React-19
@chevvy What solution do you use for this?
- Overrides were set for both package to use React-19
in my package.json:
{
"dependencies": {
"final-form": "^4.20.10",
"react-final-form": "^6.5.9",
},
"overrides": {
"react-final-form": {
"react": "19.0.0"
},
"final-form": {
"react": "19.0.0"
}
},
}
as of my comment last week, this still seems to be an adequate workaround, but your millage may vary!
Too many bugs. In our code I notice them in different places. Some fields are empty. As we have complex dynamic field generation, it is hard to isolate it to provide a minimal example. I think this version should be reverted or fixed ASAP. It was declared as "There should be NO BREAKING CHANGES" but actually it is completely broken.
I've also been experiencing this, I'll spend some time on it and see if I can get get the initial value behavior back to how it was before