Skip to content

Instantly share code, notes, and snippets.

@selfup
Created October 20, 2017 13:44
Show Gist options
  • Save selfup/63f0387906d10c5d41e59df2af948174 to your computer and use it in GitHub Desktop.
Save selfup/63f0387906d10c5d41e59df2af948174 to your computer and use it in GitHub Desktop.
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