I am using the react-select package. When i select a drop-down option, my onChange action works correctly and updates the state. But the option is not getting selected. Meaning, it doesn't show the value which is mapped to the state, instead just the default placeholder.
I think i'm missing something small, but i'm some what new to react and redux and i'm not sure what this could be. Thanks for the help in advance :)
Body.js
<Select id="input-field" value={this.props.create.selectedOption} onChange={this.props.addOption}
options={[
{ value: 'navigate', label: 'Navigate to <URL>' },
{ value: 'enter', label: 'I enter <InputValue> to the <ElementKey>' },
{ value: 'click', label: 'Click on <ElementKey>' },
]}
/>
const mapStateToProps = (state, ownProps) => {
return {
create: state.reducerCreate
}
}
Reducer.js
const initialState = {
feature: '',
scenarios: [],
activeIndex: '',
selectedOption: ''
}
<Select>
component usingstate
rather thanprops
- Danethis.props.create.selectedOption
isundefined
? Like I said, it's better if you usethis.state
to manage theSelect
component as only that will get re-rendered, instead of changingprops
- Dane