fix ArrayField initial state value #4918
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
When I am using
<SingleFieldList>
component as children of<ArrayField>
, there seems to have a race condition that will make the whole<List>
view of a resource crash sometime.The error message is:
I have traced the issue to its parent component. The useState hook is not initializing ids and data properly, setting them to undefined value. The useEffect hook will run during first render, but the state update function setIds and setData are asynchronous. This will cause the undefined ids to be passed down and ids.map function cannot be called properly.
The fix is also simple, just adding initial states.
Thank you