Within my React application, I am using the map JavaScript function to render a div multiple times. Each element needs to have a specific width set via CSS. The className for each div is unique. Here is how I am rendering the divs:
{this.props.face_clicked_reducer.person_timeline.map((item, i) => (
<div className={`marker-item-${i}`} id="sele1"></div>
))}
I need to adjust the width of each element based on {item.time}. I attempted to do this in componentDidMount like so:
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');
Unfortunately, this approach did not work as expected and no errors were reported in the console.