Open dewabagas opened 5 years ago
whenever i'm trying to reset the value , it's always goes like this,. i don't know why, i've tried everything,
I'm having the same issue. The readme says there are 3 exposed methods but I see no such methods in the code, they don't exist. @sohobloo
You can achieve this using refs:
class MyComponent extends Component {
constructor(props) {
super(props);
this.dropdownRef = React.createRef();
}
componentDidMount() {
const { value, options } = this.props;
const selectedIdx = (options || []).findIndex(option => option === value);
this.dropdownRef.current.select(selectedIdx);
}
render() {
const { options } = this.props;
return (
<ModalDropdown ref={this.dropdownRef} options={options} />
);
}
}
You can achieve this using refs:
class MyComponent extends Component { constructor(props) { super(props); this.dropdownRef = React.createRef(); } componentDidMount() { const { value, options } = this.props; const selectedIdx = (options || []).findIndex(option => option === value); this.dropdownRef.current.select(selectedIdx); } render() { const { options } = this.props; return ( <ModalDropdown ref={this.dropdownRef} options={options} /> ); } }
thank you so much. it works for me.