This is a migrated thread and some comments may be shown as answers.

Reset back Dropdown to defaultValue

1 Answer 748 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Arun
Top achievements
Rank 1
Arun asked on 05 Mar 2019, 02:49 PM

     Hi, I have a dropdown rendering a list from an array of objects. I have used the prop 'defaultValue' to have a value preselected while loading. I want to implement a clear button functionality where clicking the button resets back the selected value to the default value. Please advice.

 

Here is the stackblitz url: https://stackblitz.com/edit/react-xzennu?file=app/main.js

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 06 Mar 2019, 08:10 AM
Hello, Arun,

In this case, I can suggest using value, instead of defaultValue as using defaultValue puts the components into the uncontrolled mode:

https://reactjs.org/docs/uncontrolled-components.html

This is the updated example:

https://stackblitz.com/edit/react-xzennu-xfyqva?file=app/main.js

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Arun
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or