Open skoob13 opened 5 years ago
I'm curious, is it really expected behavior for the FormSpy
to be able to detect a change to the id
state that isn't managed by Final Form?
I don't claim to be an expert, so I hope someone who is an expert chimes in regarding your specific question about the useEffect
dependency, but I do know a couple workarounds in case that's helpful (you may have already found workarounds)...
One workaround is to simply move id
into the form (as a hidden input, for example) and let react-final-form manage it as part of its state (form.values
). Then you can use a mutator to update that state. Working example here: https://codesandbox.io/s/react-final-form-simple-example-euh8y
Another workaround is to add a key
prop:
<FormSpy
key={id}
(as seen here)
I think it's fixed by #572
Are you submitting a bug report or a feature request?
Bug report
What is the current behavior?
onChange
callback doesn't update when it updates inFormSpy
component.What is the expected behavior?
useFormState
effect should depend ononChange
callback.Sandbox Link
https://codesandbox.io/s/react-final-form-simple-example-d8www?fontsize=14
Steps to reproduce:
What's your environment?
I use React Native, but the issue persists on Code Sandbox as well.
Final Form: 4.16.1 React Final Form: 6.3.0
Other information
I'm not sure it's a bug. If it is, I will submit a pull request.