Created
October 20, 2017 13:44
-
-
Save selfup/63f0387906d10c5d41e59df2af948174 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 Person extends React.Component { | |
render () { | |
const name = this.props.name.length > 8 | |
? this.props.name.substring(0, 5) | |
: this.props.name; | |
const age = this.props.age; | |
const hobbies = this.props.hobbies.map((hobbie) => <li>{hobbie}</li>); | |
return ( | |
<div> | |
<p>Learn some information about this person</p> | |
{age >= 21 | |
? <h3>Hi {name}, have a drink</h3> | |
: <h3>Sorry {name} you must be 21 to drink</h3> | |
} | |
<ul>{hobbies}</ul> | |
</div> | |
); | |
} | |
} | |
ReactDOM.render( | |
<Person | |
name={'Alexxxxx'} | |
age={21} | |
hobbies={['football', 'soccer', 'something']} | |
/>, | |
document.getElementById('app'), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment