I am using v. 1.0.0-beta and have noticed that supplying a defaultValue
prop does not produce the expected result. I expected to be able to pass in React's native defaultValue
prop to initialize the component's value: http://facebook.github.io/react/docs/forms.html#default-value
<Select
{...props}
defaultValue="one"
value={this.state.value}
onChange={this.setValue}
/>
The react-select docs state that value
sets the "initial field value", but that doesn't work for me either.
Is defaultValue
intentionally unhandled? Am I perhaps doing it wrong?
Ah, from React's docs:
"To make an _uncontrolled_ component,
defaultValue
is used instead."
So, I suppose that means that controlled components don't use defaultValue
at all. And I see that react-select 1.0.0-beta is now a controlled component. I suppose that answers my initial questions.
Does this change mean that <Select/>
must always be wrapped now just to control the value state?
Implementing defaultValue
would be a great feature. If I have time some day I'll create a PR.
Hello -
In an effort to sustain the react-select
project going forward, we're closing old issues / pull requests.
We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our limited efforts to maintain the latest version.
If you feel this issue / pull request is still relevant and you'd like us to review it, please leave a comment and we'll do our best to get back to you.
Most helpful comment
Implementing
defaultValue
would be a great feature. If I have time some day I'll create a PR.