Created
August 3, 2016 16:18
-
-
Save ccjoel/07748168214812f716fec704634e690b to your computer and use it in GitHub Desktop.
JSX Switch Statement?
This file contains 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
render(){ | |
const { flashState } = this.props; | |
return ({ | |
({ // switch | |
SUCCESS: () => (<Component1 />), | |
INFO: () => (<Component2 />), | |
WARNING: () => (<Component3 />) }[flashState] || | |
(() => (<DefaultComponent />)))() // DEFAULT | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment