Tuesday, November 6, 2018

React Components in loop

How to create dynamic react component in loop

state={

  Userinfo:[

    { name: 'Ravish Jha', Location: 'India'},

    { name: 'Ritika Jha', Location: 'USA'},

    { name: 'Raju Jha', Location: 'UK'}

  ]

} 
 
render() {
return (
<div className="App">
{
this.state.Userinfo.map(info => {
return <Useroutput UserName= {info.name}
UserLocation
={info.Location} />
})}
</div>
);
}
 

No comments:

Post a Comment