Select component does not update when "defaultValue" changes.
See original GitHub issueI’m using a select dropdown with a dynamic defaultValue
prop. When the value supplied to defaultValue
changes, but the rendered select dropdown still shows the previous defaultValue. My component is uncontrolled.
<Select defaultValue={ data.default }>
{
data.options.map(option => (
<Option value={ option }> { option } </Option>
))
}
</Select>
Antd version 2.5.2
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
react-select not showing default value and not updating
You're setting the Select value to form.natureOfTheRequest , so you need to update that specific field on its onChange callback, ...
Read more >Re-render DefaultValue when Value Changes in React
React will never update the input tag if the value passed to defaultValue changes. It was meant to be a default/starting value only,...
Read more >How to set default value in select using ReactJS
Following are the two approaches to set default value in select using ReactJS: Approach 1: Without using React Select component.
Read more >Component prop not changing when select value changes ...
Component prop not changing when select value changes · Test that a component does not render when passed a certain prop value with...
Read more >Element: <oj-select-single> - Oracle
Examples of actions are - creating a component, user changing the ... If there are no errors, then the value property is updated...
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
@pastelsky You should use
value
. Try learning controlled/uncontrolled component concept in React.To anyone facing a similar issue, do read https://github.com/facebook/react/issues/4101 . React dropdowns have this slightly confusing behaviour and the only way to force re-render without making it a controlled component is by introducing a “key= {defaultValue}”