react-final-form
react-final-form copied to clipboard
initialValue overrides state on update
Bug
What is the current behavior?
Currenlty the initialValue is being used when the component is updated, and resets the form state.
See this question: https://stackoverflow.com/questions/54635276/react-final-form-set-initialvalues-from-props-form-state-resets-on-props-chang
The solution is to memoise the value like: const initVals = useMemo(() => initialValues, [])
What is the expected behavior?
I think the initialValue should only ever be used on the initial render, and not update and reset the form state to the initialValues, as long as they don't change. Although even then I don't think it's appropriate, because it's what I'm used to with input components from libs like @mui
Solution?
I think changing this behaviour might break a lot of use-cases, but perhaps it's a good idea to deprecate the current behaviour of initialValue, and move that effect to the the value prop.
Could the Form's subscription prop solve the issue?
subscription doesn't help anymore.