Skip to content

Instantly share code, notes, and snippets.

@davidmh
Created September 15, 2018 17:37
Show Gist options
  • Save davidmh/4f0902fdc9bf0dbb9bafbd937bb883b9 to your computer and use it in GitHub Desktop.
Save davidmh/4f0902fdc9bf0dbb9bafbd937bb883b9 to your computer and use it in GitHub Desktop.
toggle selected trip
diff --git a/src/App.js b/src/App.js
index b8ec935..04a4045 100644
--- a/src/App.js
+++ b/src/App.js
@@ -30,9 +30,10 @@ class App extends Component {
}
selectTrip = tripId => {
- this.setState({
- selectedTrip: tripId
- });
+ const selectedTrip = this.state.selectedTrip === tripId
+ ? undefined
+ : tripId
+ this.setState({ selectedTrip });
};
selectBus = busId => {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment