-
-
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
Add an option to make ReferenceArrayInput lazy #5898
Comments
As I understand it, you have two ReferenceArrayInput on the same reference but with different sources. The fact that ReferenceArrayInput fetches the possible options on mount is by design. If you want a component that does it lazily, you'll have to write your own. As for not batching the calls for the possible values, I'm not sure I can reproduce. In the simple example, where we have an ArrayInput, if I edit a post and add several authors to it, then navigate away and back, I can see that the form only loads the list of possible authors once. So for this second problem, please attach a link to a fork of the simple codesandbox demonstrating the issue. Finally, please follow the issue template so that we know at least the version of react-admin you're using. |
Yes you understand it right. Given that they are in an I'll look into making my own then. Regarding the codesandbox, I actually tried to use it yesterday but I see a white page on https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple. There is an error about Thus, here an example showing what I wrote regarding batching: https://codesandbox.io/s/zealous-leakey-o5oxt?file=/src/posts/PostEdit.js (output-only version). Finally, I actually followed the issue template but it was the "feature request" one. |
I think that in order to have a "lazy" behaviour while still using the |
Implemented in #6013 for |
Is your feature request related to a problem? Please describe.
I'm building an edit form where one of the input is an
ArrayInput
. Each item of this input is aSimpleFormIterator
with a few fields. Some of these fields are using aReferenceArrayInput
with anAutocompleteArrayInput
.Here's an example:
The
categories
resource has a lot of items and so I'd like to fetch them only if the user enters at least 2 characters. However, even if the autocomplete doesn't show the option, eachReferenceArrayInput
is fetching the data with noq
param (/categories?_end=25&_order=DESC&_sort=id&_start=0
).Another issue I noticed is that requests from the
ReferenceArrayInput
are not batched. In the above example, if I'm editing a resource with 3 items, there are 6 requests sent to/categories?_end=25&_order=DESC&_sort=id&_start=0
when opening the form.Describe the solution you'd like
Ideally, a
lazy
option would be nice. Its purpose would be to only fetch the data for an autocomplete if theshouldRenderSuggestions
returnstrue
.Describe alternatives you've considered
Another possibility would be to have all similar requests batched in the example I mentioned above.
The text was updated successfully, but these errors were encountered: