Answer the question
In order to leave comments, you need to log in
How to pass DOM via prop?
I am writing a video player.
<div id="media-player" className="small-12 small-centered large-centered">
<video id="media-video"
width="100%"
src=""
controls
ref={(player) => this.mediaPlayer = player}>
</video>
<PlayerControls/>
</div>
<video/>
) and the controls component (ProgressBar, Play/Pause...). So, all the actions inside the controls I need to carry out inside the controls themselves, but they will act on the DOM element <video/>
. Is it possible to somehow pass this component inside, like for example <PlayerControls player={this.mediaPlayer}/>
? Tried in Component Lyfecycle methods, but there it is not rendered yet and therefore Null. And on DidMount, my controls are already rendered. Answer the question
In order to leave comments, you need to log in
Wouldn't it be easier to make a common parent for video and controls?
<mediaPlayer>
<video ref={(v) => this.video = v} />
<playerControls onStop={...} onPlay={...} onPause={...} />
</mediaPlayer>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question