Skip to content

Instantly share code, notes, and snippets.

@ccjoel
Created August 3, 2016 16:18
Show Gist options
  • Save ccjoel/07748168214812f716fec704634e690b to your computer and use it in GitHub Desktop.
Save ccjoel/07748168214812f716fec704634e690b to your computer and use it in GitHub Desktop.
JSX Switch Statement?
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