Last active
February 26, 2017 11:23
-
-
Save nicohvi/bd4b270de2595d6240bfb6ff96530b19 to your computer and use it in GitHub Desktop.
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
class PokemonGym extends React.Component { | |
renderBattle () { | |
const { trainer } = this.props; | |
switch(trainer) { | |
case "Annoying school boy": | |
return this.schoolBoy(); | |
case "Pretentios nerd": | |
return this.nerd(); | |
case "Brock": | |
return this.brock(); | |
default: | |
console.error(`trainer not found: ${trainer}`); | |
return null; | |
} | |
} | |
render () { | |
return <section className="gym-battle"> | |
{this.renderBattle()} | |
</section>; | |
} | |
} |
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
class PokemonGym extends React.Component { | |
constructor(props) { | |
super(props); | |
this.renderBattle = R.cond([ | |
[R.eq('Annoying school boy'), () => <SchoolBoy />], | |
[R.eq('Pretentios nerd', () => <Nerd />] | |
[R.eq('brock', () => <Brock />], | |
[R.T, () => null] | |
]); | |
} | |
render () { | |
const { trainer } = this.props; | |
return <section className="gym-battle"> | |
{this.renderBattle(trainer)} | |
</section>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment