mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
improvement: use useCallback instead of setting ref auto-magically
This commit is contained in:
parent
fa95a041dd
commit
37011c2fda
@ -41,11 +41,16 @@ export const HistoryVideo = ({
|
|||||||
videoUrl: '',
|
videoUrl: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
const videoCallback = useCallback(
|
||||||
if (posterLoaded && videoRef.current) {
|
(domNode: any) => {
|
||||||
|
videoRef.current = domNode;
|
||||||
|
|
||||||
|
if (posterLoaded) {
|
||||||
setVideoHeight(videoRef.current?.offsetHeight);
|
setVideoHeight(videoRef.current?.offsetHeight);
|
||||||
}
|
}
|
||||||
}, [posterLoaded, videoRef.current]);
|
},
|
||||||
|
[posterLoaded]
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const idExists = !isNullOrUndefined(id);
|
const idExists = !isNullOrUndefined(id);
|
||||||
@ -123,7 +128,7 @@ export const HistoryVideo = ({
|
|||||||
const { posterUrl, videoUrl } = videoProperties;
|
const { posterUrl, videoUrl } = videoProperties;
|
||||||
return (
|
return (
|
||||||
<video
|
<video
|
||||||
ref={videoRef}
|
ref={videoCallback}
|
||||||
key={posterUrl}
|
key={posterUrl}
|
||||||
onTimeUpdate={onTimeUpdateHandler}
|
onTimeUpdate={onTimeUpdateHandler}
|
||||||
onPause={onPause}
|
onPause={onPause}
|
||||||
|
Loading…
Reference in New Issue
Block a user