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: '',
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (posterLoaded && videoRef.current) {
|
||||
const videoCallback = useCallback(
|
||||
(domNode: any) => {
|
||||
videoRef.current = domNode;
|
||||
|
||||
if (posterLoaded) {
|
||||
setVideoHeight(videoRef.current?.offsetHeight);
|
||||
}
|
||||
}, [posterLoaded, videoRef.current]);
|
||||
},
|
||||
[posterLoaded]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const idExists = !isNullOrUndefined(id);
|
||||
@ -123,7 +128,7 @@ export const HistoryVideo = ({
|
||||
const { posterUrl, videoUrl } = videoProperties;
|
||||
return (
|
||||
<video
|
||||
ref={videoRef}
|
||||
ref={videoCallback}
|
||||
key={posterUrl}
|
||||
onTimeUpdate={onTimeUpdateHandler}
|
||||
onPause={onPause}
|
||||
|
Loading…
Reference in New Issue
Block a user