Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
add check for to handle where `selectedOption` is null in the example `handleChange` function
  • Loading branch information
spankie committed May 25, 2018
1 parent 02ad75e commit fddbc5c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ class App extends React.Component {
}
handleChange = (selectedOption) => {
this.setState({ selectedOption });
console.log(`Selected: ${selectedOption.label}`);
// selectedOption can be null when the `x` (close) button is clicked
if (selectedOption) {
console.log(`Selected: ${selectedOption.label}`);
}
}
render() {
const { selectedOption } = this.state;
Expand Down

0 comments on commit fddbc5c

Please sign in to comment.