Autocomplete is changing the uncontrolled value state to be controlled.
See original GitHub issueDescribe the bug Autocomplete is changing the uncontrolled value state to be controlled when choosing option
To Reproduce Steps to reproduce the behavior:
- Go to codesandbox
- Try choose any option
- See console.
Expected behavior Shouldn’t change state
I think this is due to the fact that the defaultValue
remains undefined
if getOption
was passed but value was not.
Maybe set to null
by default, because from react-final-form:
By default, if your value is null, <Field/> will convert it to ‘’, to ensure controlled inputs
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:22 (12 by maintainers)
Top Results From Across the Web
A component is changing an uncontrolled Autocomplete to be ...
If you pass value={undefined} to the Autocomplete component, it will start in "uncontrolled" mode, meaning it keeps its own internal state.
Read more >[Autocomplete] "A component is changing the controlled value ...
Material-UI : A component is changing the controlled value state of Autocomplete to be uncontrolled. Elements should not switch from ...
Read more >A component is changing an uncontrolled input to be controlled
The warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to...
Read more >A component is changing an uncontrolled Autocomplete to be ...
These two state are isolated, they should be controlled independently. Component becomes uncontrolled when inputValue property is undefined, and vice versa.
Read more >a component is changing the uncontrolled value state of ...
The warning "A component is changing an uncontrolled input to be controlled" occurs when an input value is initialized to undefined but is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Lucas-Alf Thanks for the update. I’ve reopened for now until myself or someone else can find the time to investigate this further.
I had a similar problem trying to create a Autocomplete component with server side data fetch. Try to remove this line and see if stops giving that error: https://github.com/lookfirst/mui-rff/blob/646a5393705093508fad8acedecbdda11584d0b7/src/Autocomplete.tsx#L150
Looks like is something with the defaultValue equals to undefined. For my custom component i just removed this line and the problem is gone, i really don’t need the defaultValue in my use case.
If someones wants see my component (not TS): https://github.com/Lucas-Alf/resoar/blob/main/src/components/AutocompleteServerSide/AutocompleteAdapter.jsx