Reputation: 9560
const imageHtml = imageDescription.map((article, index) => {
return (
<div style={{ backgroundImage: "url(/images/Large/" + article.imagePath + ".jpg)" }}>
</div>
)
})
I am doing a slider thing but i faced a problem, how to apply left property for a specific article? For example applying left = 20px for only index 1?
Upvotes: 0
Views: 55
Reputation: 14375
You can either give left=0 for the rest:
<div style={{backgroundImage: ..., left: (index === 1 ? 20 : 0)}} />
or, if you prefer to not include it at all:
<div style={Object.assign({backgroundImage: ...}, (index === 1 ? {left: 20} : {}))} />
Upvotes: 1