Hi devs im learning React and i want to know if there's a method to grab an element from my array and style it with css.
const card = [ { id: 1, title: "DEEP EARTH", Background: "images/earth.jpg", }, { id: 2, title: "NIGHT ARCADE", Background: "images/arcade.jpg", }, { id: 3, title: "SOCCER TEAM VR", Background: "images/soccer.jpg", } ]
As early was said you can use map and inline styles
return (<div> {card.map((item) => ( <div key={item.id}>{item.title} styles={{background:url(item.src)}} > </div> ))} </div>);
2.1m questions
2.1m answers
60 comments
57.0k users