Last active
July 25, 2017 08:50
-
-
Save dineshPallapa/45a3c474081c9df1990729efe16c4ae8 to your computer and use it in GitHub Desktop.
Edit on codepen https://codepen.io/dineshPallapa/pen/mMddbZ
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 Profile extends React.Component{ | |
render() { | |
let hobbies = this.props.hobbies.map(hobbie => { | |
return( | |
<li>{hobbie}</li> | |
) | |
}) | |
return( | |
<div> | |
<h3>{this.props.name}</h3> | |
<h3>{this.props.age}</h3> | |
<ul>{hobbies}</ul> | |
</div> | |
) | |
} | |
} | |
class App extends React.Component{ | |
constructor(props) { | |
super(props) | |
this.state = { | |
name:"Dinesh", | |
profiles: [ | |
{name:"dinesh",age :23,hobbies:["Playing cards","Mobile games"]}, | |
{name:"Virus",age:24,hobbies:["eating","sleeping"]} | |
] | |
} | |
} | |
render() { | |
let profiles = this.state.profiles.map(profile => { | |
return( | |
<Profile name={profile.name} | |
age={profile.age} | |
hobbies={profile.hobbies} | |
/> | |
) | |
}) | |
return ( | |
<div> | |
{profiles} | |
<Profile name={"dinesh"} age={20} hobbies={["eating","drinking"]} /> | |
</div> | |
) | |
} | |
} | |
ReactDOM.render( | |
<App />, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment