Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-select onChange not working after change options

Tags:

I have a component using react-select, I get the options from props, on selct option I want to rerender the select with other options - it works, but onChange not triggered.

import Select from 'react-select';

onChange(option){ 
   dispatch(updateOptions());
}

render(){
  return 
    <Select
      options={this.props.options}
      onChange={this.onChange}
      value={this.state.text}
      menuIsOpen
    />
} 
like image 668
user10391869 Avatar asked Jun 18 '20 13:06

user10391869


1 Answers

Please have a look at this example, I have created two components one as a Functional Component and the other as Class Component.

Hope this helps.

like image 168
Nithish Avatar answered Sep 30 '22 19:09

Nithish