Warning: Cannot update a component (`ForwardRef(Field)`) while rendering a different component (`ForwardRef(Field)`)
Author: slowselfipCreated Aug 25, 2020Updated Feb 16, 2026
Are you submitting a bug report or a feature request?
Bug report
What is the current behavior?
A react warning about "invalid set state in render" is shown when rendering the value of a conditionally rendered field that has an initialValue set.
What is the expected behavior?
That React does not print warnings in the console.
Sandbox Link
https://codesandbox.io/s/tender-sea-6fmu3?fontsize=14&hidenavigation=1&theme=dark
What's your environment?
{
"react": 16.13.1,
"react-dom": 16.13.1,
"react-final-form": 6.5.1,
"react-scripts": 3.4.1,
"final-form": 4.20.1
}Other information
Note that the example is a bit contrived and that the real life scenario causing is a bit more complex.
This issue might be related to https://github.com/final-form/react-final-form/issues/828. That issue is regarding a FormSpy and this is related to a conditionally rendered Field with initialValue prop.
Thanks for taking the time and hope this can help in some way.
Source: final-form/react-final-form