Created
September 15, 2018 17:37
-
-
Save davidmh/4f0902fdc9bf0dbb9bafbd937bb883b9 to your computer and use it in GitHub Desktop.
toggle selected trip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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