I am rendering a div multiple times by using map javascript function in my react application. I want to set css (width) of each element. Width will be element specific. I am rendering div like this
{this.props.face_clicked_reducer.person_timeline.map((item, i) => (
<div className= {`marker-item-${i}`} id="sele1"></div>
))
}
className of each div is different. How can I set css of each element. For setting width I will be needing {item.time} reference.
I tried setting it in componentDidMount like this
this.props.face_clicked_reducer.person_timeline.map((item, i) => (
$("<div className= {`marker-item-${i}`}></div>").css({
"width": ((item.endTime - item.startTime) * (100/this.props.player_time_update_reducer.video_duration)) + '%',
"left": ((item.endTime) * (100/this.props.player_time_update_reducer.video_duration)) + '%'
})
)).css('backgorund', 'red')
But it didn't work. I am not getting any errors in console.