mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-11 05:26:15 -08:00
update template
This commit is contained in:
1 parent
145d6b7a96
commit
af9f9b3263
2 files changed
+20
-19
No files matched your search
@@ -1,25 +1,25 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import Artplayer from "artplayer";
|
||||
import { useEffect, useRef } from 'react';
|
||||
import Artplayer from 'artplayer';
|
||||
|
||||
export default function ({ option, getInstance, ...rest }) {
|
||||
const artRef = useRef();
|
||||
const artRef = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
const art = new Artplayer({
|
||||
...option,
|
||||
container: artRef.current,
|
||||
});
|
||||
useEffect(() => {
|
||||
const art = new Artplayer({
|
||||
...option,
|
||||
container: artRef.current,
|
||||
});
|
||||
|
||||
if (getInstance && typeof getInstance === "function") {
|
||||
getInstance(art);
|
||||
}
|
||||
if (getInstance && typeof getInstance === 'function') {
|
||||
getInstance(art);
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (art && art.destroy) {
|
||||
art.destroy(false);
|
||||
}
|
||||
};
|
||||
}, [option, getInstance]);
|
||||
return () => {
|
||||
if (art && art.destroy) {
|
||||
art.destroy(false);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
return <div ref={artRef} {...rest}></div>;
|
||||
return <div ref={artRef} {...rest}></div>;
|
||||
}
|
||||
@@ -19,7 +19,8 @@ export default function Player({ option, getInstance, ...rest }) {
|
||||
art.destroy(false);
|
||||
}
|
||||
};
|
||||
}, [option, getInstance]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return React.createElement('div', {
|
||||
ref: artRef,
|
||||
|
||||
Reference in new issue
Block a user