I'm new to Reactjs. I'm trying to make a story player (like audio player but with stories).
https://i.stack.imgur.com/WX6sI.jpg
render() {
const storiesList = this.props.stories;
return(
<div>
{
storiesList.map((story, k) => {
return(
<div
ref={this.myRef}
key={k}
className="story"
onClick={() => this.playAudio(story.playing_url)}
onChange={console.log(this.myRef.current)}
>
<img
src={story.image_url}
className="story-img"
alt="story"
/>
<div className="story-play">
<div className="story-play-inner">
{
this.state.playing_story === story.playing_url && this.state.playing
? <span>| |</span>
: <span>▶</span>
}
</div>
</div>
<p className="story-name">
{story.name}
</p>
</div>
)
})}
<div className="progress-bar" >
<div className="playBtn">
<span>▶</span>
</div>
<div className="progress-container">
<div className="progress-title">
<span>Story name</span>
</div>
<div className="timeline">
<div className="playhead"></div>
</div>
<div className="progress-time">
<span className="progress-time-played">4:55 </span>
<span className="progress-time-total">/ 8:15</span>
</div>
</div>
</div>
</div>
)
}
}
When I console log the refs it always returns the same 4 stories. How can I access the ref of the element I'm clicking on? I need to do it so I can render the story name on the progress bar.