-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[BUG] - Maximum update depth exceeded on Autocomplete component #3094
Comments
I ran into this issue as well, same version. I found a workaround that isn't the worst, but hopefully sharing it will help with the debugging process: This is what is currently not working, and throwing the depth exceeded error
And if you instead check if the argument passed to onSelectionChange is truthy before setting state, it works fine:
This could cause issues with clearing values, so another workaround would be to check if the typeof e is "string" before setting the value, then if e === null, set the value to "". I confirmed that this works as well. |
Can confirm that this is still an issue in NextUI 2.4.1 |
@TheUntraceable I don't see autocomplete component in your sandbox. Did you forget to save? |
NextUI Version
2.3.6
Describe the bug
I have an Autocomplete Component
where countries is a list of objects with the key "value".
When an item is selected, if the dropdown menu is triggered from the arrow and all the items are displayed, if I select on a new item I get the error:
"Error: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops."
with Call Stack :
"onSelectionChange
node_modules@react-stately\combobox\dist\useComboBoxState.mjs (31:1)
onChangeCaller
node_modules@react-stately\utils\dist\useControlledState.mjs (29:1)
Object.eval [as setSelectedKey]
node_modules@react-stately\utils\dist\useControlledState.mjs (54:1)
setSelectedKey
node_modules@nextui-org\autocomplete\dist\chunk-SYFYBWAI.mjs (173:13)"
If I remove the {item.value} child in the AutocompleteItem, the error goes away, but the country items are not displayed neither on the input nor the dropdown list.
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Click on the arrow of autocomplete item to toggle the dropdown list when an item is already selected and select a new item
Expected behavior
I expected for just the new item value to be displayed
Screenshots or Videos
No response
Operating System Version
Windows
Browser
Chrome
The text was updated successfully, but these errors were encountered: