You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can see, the values are rendered in the first cycle. Then StrictMode unmounts the fields, causing them to be removed from the form model (caused by 'destroyOnUnregister'). On the second mount, the initial values are considered to be identical, hence the fields will not be filled again but remain empty.
When running in production (i.e. w/o StrictMode) the form is filled. The form will also work correctly if:
You disable StrictMode locally
You remove the destroyOnUnregister attribute
You overwrite 'initialValuesEqual' with () => false
The text was updated successfully, but these errors were encountered:
Strict Mode is a Breaking Change in React 18...
It emulates unmounting and remounting the fields which would then obviously clear all the values from the formState.
Hi!
I recently did a project on which we relied a lot on destroyOnUnregister and I'd be hard to implement the same feature with a FormSpy so I looked into your suggestion.
It's a bit complicated to try and handle correctly the behavior when you have dependencies or changing effect function ( the code in the link broke quite a lot of tests in final-form
It looks like it would be hard to bring the tests in react-final-form as they are only valid for react 18.
Do you think there's a way I can do a PR to fix that behavior ?
Type of issue
Bug
What is the current behavior?
When opening a form with the attribute 'destroyOnUnregister' in StrictMode locally, the initial Values are not displayed.
What is the expected behavior?
When opening a form with the attribute 'destroyOnUnregister' in StrictMode locally, the initial Values are displayed.
Sandbox Link
See https://codesandbox.io/s/inspiring-cori-smyfhm?file=/src/App.js
What's your environment?
react-final-form: 6.5.9
final-form: 4.20.9
react: 18.2
Other information
As far as I can see, the values are rendered in the first cycle. Then StrictMode unmounts the fields, causing them to be removed from the form model (caused by 'destroyOnUnregister'). On the second mount, the initial values are considered to be identical, hence the fields will not be filled again but remain empty.
When running in production (i.e. w/o StrictMode) the form is filled. The form will also work correctly if:
The text was updated successfully, but these errors were encountered: