Ant Design Form failing to sync with asynchronous initialValues
0 reputation · 05 Apr 2021, 05:41 UTC
The Ant Design Form component typically relies on the initialValues prop to populate fields during initialization. However, when data is fetched via an asynchronous operation, a race condition often occurs if the promise resolves after the Form component has already mounted.
In these scenarios, the internal FormInstance may remain empty or reflect the initial state despite the new data being passed to the prop. While setFieldsValue is often suggested as a manual workaround, it introduces risks of unnecessary render loops or state inconsistencies if not integrated precisely with the component lifecycle.
Does the Form component programmatically trigger a re-evaluation of initialValues if they change post-mount? What is the recommended pattern to ensure the internal store synchronizes with dynamic data without manually bypassing the declarative prop logic?