Can't give only the value in props, it's only working with full object option
See original GitHub issueFor these options:
const options = [{ value: 1, label: "one" }, { value: 2, label: "Two" }]
In React Select v1.x.x, you could do this to select the first option:
<Select
value={1}
options={options}
/>
Now in React Select v2, you have to do this:
<Select
value={{ value: 1, label: "one" }}
options={options}
/>
I guess it’s a bug since it’s not documented anywhere (not mentionned in Upgrade Guide).
Non-working example: https://codesandbox.io/s/l946w963r7
Issue Analytics
- State:
- Created 5 years ago
- Reactions:24
- Comments:16 (1 by maintainers)
Top Results From Across the Web
Cannot assign to read only property 'props' of #<Object> in ...
You cannot push to props this.props.nav.push({id: 'Applist', index: 2}); since component properties are read-only, as the error states.
Read more >How passing props to component works in React
Master how to pass props (properties) to components in React with this useful beginner's guide, including demo code.
Read more >React Props Cheatsheet: 10 Patterns You Should Know
In this tutorial, we will be reviewing ten patterns you should use when working with props in React. We will not only touch...
Read more >Accessing Data through Props with Known Key Names in ...
Through this guide, you will learn the different approaches to access the key-value pair of the props and state objects in a React...
Read more >Updating Objects in State - React Docs
While mutating state can work in some cases, we don't recommend it. You should treat the state value you have access to in...
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 Free
Top 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
Taking away the simple value as the default functionality was a bad decision.
I think someone needs to fork this library and put it back the way it was. Anyone willing to help with this?
I ended up going this route:
Props with full object options, and value is an array of values;
getValue returns the proper
{value: x, label: y}
objects for values;renderable