Skip to content
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

How to reset selectedItem? #203

Open
vmusulainen opened this issue Aug 14, 2024 · 1 comment
Open

How to reset selectedItem? #203

vmusulainen opened this issue Aug 14, 2024 · 1 comment

Comments

@vmusulainen
Copy link

vmusulainen commented Aug 14, 2024

I have 5 selectors that are populated sequentially - the values ​​in each selector depend on the selection of the previous selector.

At the beginning, all 5 selectors are populated with default values ​​using the defaultValue property.

It needs to reset selected item at the subsequent selectors when the user changes the selection in the parent selector.

I was thinking of setting defaultValue to undefined, and that would reset the selection, but it doesn't work.

How can I do that?

@hungtrinh-asi
Copy link

You can use ref to reset the selected item like this:

<SelectDropdown
 ref={selectRef}
data=[]
...
/>

Then:
selectRef.current.reset();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants