Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ArrayField initial state value #4918

Merged
merged 1 commit into from
Jun 9, 2020
Merged

fix ArrayField initial state value #4918

merged 1 commit into from
Jun 9, 2020

Conversation

smeng9
Copy link
Contributor

@smeng9 smeng9 commented Jun 8, 2020

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:

TypeError: ids is undefined

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

@smeng9
Copy link
Contributor Author

smeng9 commented Jun 8, 2020

Related Issue #4916
&
Related PR #4536

@djhi
Copy link
Contributor

djhi commented Jun 9, 2020

Thanks!

@djhi djhi added this to the 3.6.1 milestone Jun 9, 2020
@djhi djhi merged commit ae64892 into marmelab:master Jun 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants