-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
ArrayInput breaks when value is null #7754
Comments
Hi, and thank you for submitting this. Maybe we could detect this on our side and replace the value with an empty array, but I'm not really sure about the impacts this would have. Can you tell us more about your use case? Thanks |
Use case being that some field values are null. This is only an issue with rendering array inputs, all other inputs appear to render fine when a field value is null. Since react-hook-form doesn't like null values for arrays the only work around for this right now is to remove all |
Okay so actually, this problem seems to have been solved as of react-hook-form v7.29.0 (although I can't find evidence in the changelog). |
Fixed by #7768 |
Hi, i still can see this issue on react admin 4.2.4... EDIT: workaround for me is to filter out the response in the dataprovider... |
Indeed and it seems that it is expected in |
According to me this should be fixed on react-hook-form's side (the 'map' error actually comes from their code). That's what I tried to argue here react-hook-form/react-hook-form#4826 (comment) . I don't see how we could fix this in RA, since we do not know upfront if a given field will be used inside an Best we could do is mention in the docs that the value cannot be |
@slax57 |
I'm not sure this is a bug or if this was intended with 4.x version of react-admin.
What you were expecting:
ArrayInputs render when field value is null.
What happened instead:
A
cannot read properties of null (reading 'map')
error is thrown here in react-hook-form: https://github.com/react-hook-form/react-hook-form/blob/v7.27.0/src/useFieldArray.ts#L103. It appears unless a field value is undefined react-hook-form will not default to an empty array. Based on line 101 unless a field value is undefined react-hook-form will not default to an empty array.Steps to reproduce:
Set any field value in the v4 sandbox test data.tsx file intended to be rendered with ArrayInput to
null
(ie: 'backlinks').You can see the error here in this sandbox when you navigate to the edit view for post with id 1. https://codesandbox.io/s/boring-benz-5odpst
Environment
The text was updated successfully, but these errors were encountered: