Skip to content

Instantly share code, notes, and snippets.

@clc80
Last active August 15, 2018 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clc80/458a6fed301766a3f8425ae787166183 to your computer and use it in GitHub Desktop.
Save clc80/458a6fed301766a3f8425ae787166183 to your computer and use it in GitHub Desktop.
class Person extends React.Component {
render() {
var age = this.props.age;
var message = "";
if (age >= 21 ){
message = "Have a Drink!"
} else {
message = "You must be 21"
}
var name = this.props.name;
if (name.length > 8) {
name = name.slice(0, 6);
}
return (
<div>
<p>Learn some information about this person</p>
<p>{name}</p>
<h3>{message}</h3>
<ul>
{this.props.hobbies.map(hobby => {
return (<li>{hobby}</li>);
})}
</ul>
</div>
);
}
}
ReactDOM.render(<Person name="Claudia" age = "22" hobbies = {["flying", "knitting", "reading"]} />, document.getElementById('app'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment