I'm using a redux-form and have a custom component that uses react-select.
I have created dropdown that has prefilled options and also allows custom input into that dropdown box. I am using the "creatable" componant from react-select.
I want to be able to have one of the options as the default value on first load, this option would be highlighted in the dropdown list as selected too. I have achieved this but the only problem is, if I choose a new value or create a new value it stays as the default value - although the json does change to the correct value.
Here is my codesandbox example - https://codesandbox.io/s/jvzko04ok3
In my example you will see that Jim is selected by default, but as soon as you change the select option to something else the json values change but the view does not. Have a feeling its a onBlur or onChange issue.
There has been version changes to the react-select docs over the years, a default value can be specified using value
or defaultValue
.
<CreatableSelect
{...props}
options={props.options}
onChange={value => input.onChange(value)}
onBlur={() => input.onBlur(input.value)}
value={props.options[1]}
/>