Use the map() Function. Also, there’s no need to use Component. Use functional components instead if you don’t need state. Here’s the full code:
map()
function TinTinTile() { const list = jsonResponse.characters.map((item, index) => { return ( <li className="list-container" key={index}> <img className="image-container" src={item.image_url} alt="kir" /> <div className="text-container"> <h4>Name: {item.name}</h4> <p>Job: {item.job}</p> <p>Age: {item.details.age}</p> <button className="btn">More details ...</button> </div> </li> ); }); return ( <ul id="container" className="cf"> {list} </ul> ); }
Great! Thanks a lot.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Use the
map()
Function. Also, there’s no need to use Component. Use functional components instead if you don’t need state. Here’s the full code:Great! Thanks a lot.