Open pankajsoni19 opened 4 years ago
In your onSelectedChanged handler function, you can decide whether to update the state object or not:
onSelectedChanged
const maxSelected = 3; const { options, selected } = this.state; <MultiSelect options={options} selected={selected} onSelectedChanged={(newSelected) => { if (newSelected.length <= maxSelected) { // Number of Selections is OK, save to state... this.setState({selected: newSelected}) } else { console.log("Too many selected"); } }} />
In your
onSelectedChanged
handler function, you can decide whether to update the state object or not: