Replies: 1 comment 1 reply
-
Greetings @Manubi ,
This can be frustrating when say for example you are waiting for data from an api to know what the The following should work for your use-case: const MySelect = props => {
const [ value, setValue ] = useState(props.value || props.defaultValue);
const onChange = selected => {
setValue(selected);
props.onChange && props.onChange(selected);
}
return <Select {...props} value={value} onChange={onChange} />
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi!
I have problems with react-select. I am setting the defaultValue, but as props change the defaultValue doesn't change to the correct state.
The problem is react-select has the old props data. It renders, but doesn't update if the new props are available. It should change from Röteln to Staupe.
Any hints?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions