mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 21:27:05 +00:00
use new react ref api in HTMLVideo
This commit is contained in:
parent
da602e9136
commit
da90aa7cd1
1 changed files with 8 additions and 6 deletions
|
|
@ -3,8 +3,14 @@ import PropTypes from 'prop-types';
|
|||
import HTMLVideo from './HTMLVideo';
|
||||
|
||||
class ReactHTMLVideo extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.videoRef = React.createRef();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.video = new HTMLVideo(this.videoElement);
|
||||
this.video = new HTMLVideo(this.videoRef.current);
|
||||
this.video.addListener('propChanged', this.props.onPropChanged);
|
||||
this.video.addListener('propValue', this.props.onPropValue);
|
||||
this.video.addListener('error', this.props.onError);
|
||||
|
|
@ -25,17 +31,13 @@ class ReactHTMLVideo extends Component {
|
|||
return false;
|
||||
}
|
||||
|
||||
assignVideoElement = (videoElement) => {
|
||||
this.videoElement = videoElement;
|
||||
}
|
||||
|
||||
dispatch = (...args) => {
|
||||
this.video.dispatch(...args);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<video ref={this.assignVideoElement} className={this.props.className}></video>
|
||||
<video ref={this.videoRef} className={this.props.className}></video>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue