Fix unnecessary AutocompleteArrayInput filter reset #4653
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.
Fixes #4454
Ok, this solution is not the best I can find.
@fzaninotto's idea is to let the user deal this situtation.
If the user write a tricky
parse
function, it's his job to make sure the input do not refresh too much by having a useMemo or useCallback above.The issue is that I can't make it work since
parse
is a function that I cannot define with its value.Considered alternatives
Force the user who wrote the parse function to wrap the AutocompleteArrayInput into an appropriate memo or useCallback
The issue is that I didn't succeed so because we can't access to the input values outside of this component, so we can't use it as a dependency for useCallback, for example
I didn't tried with a FormDataConsumer, it would not be developer friendly IMHO
Use
hash-sum
to hashinput.value
inside the useEffect dependency. It works, but I'm wondering if it's necessary to add a new library in the dependencies for that purpose