This commit is contained in:
Harvey committed 2021-12-10 08:36:46 +08:00
1 parent dc2345306c
commit a6917400c3
10 files changed
+110 -17

No files matched your search

@@ -0,0 +1,36 @@
import React from 'react';
import Artplayer from '../../';
export default class ArtplayerReact extends React.Component {
constructor(props) {
super(props);
this.instance = null;
this.artRef = React.createRef();
}
componentDidMount() {
const { option, getInstance } = this.props;
this.instance = new Artplayer({
...option,
container: this.artRef.current,
});
if (getInstance && typeof getInstance === 'function') {
getInstance(this.instance);
}
}
componentWillUnmount() {
if (this.instance && this.instance.destroy) {
this.instance.destroy();
}
}
render() {
const { option, getInstance, ...rest } = this.props;
return React.createElement('div', {
ref: this.artRef,
...rest,
});
}
}