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 usingstaterather thanprops- Danethis.props.create.selectedOptionisundefined? Like I said, it's better if you usethis.stateto manage theSelectcomponent as only that will get re-rendered, instead of changingprops- Dane