From fddbc5c11cbf59169c63a4a1d158de081a9c9176 Mon Sep 17 00:00:00 2001 From: Odohi David Date: Fri, 25 May 2018 20:06:04 +0100 Subject: [PATCH] Update README.md add check for to handle where `selectedOption` is null in the example `handleChange` function --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a519ec44ca..279e7075f1 100644 --- a/README.md +++ b/README.md @@ -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;