Last active
August 15, 2018 17:08
-
-
Save clc80/458a6fed301766a3f8425ae787166183 to your computer and use it in GitHub Desktop.
This file contains 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() { | |
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