Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
serhii1030 committed Apr 18, 2024
1 parent 6c2c0a1 commit 6cb3222
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,15 @@ function BaseVideoPlayer({

// use `useLayoutEffect` instead of `useEffect` because ref is null when unmount in `useEffect` hook
// ref url: https://reactjs.org/blog/2020/08/10/react-v17-rc.html#effect-cleanup-timing
useLayoutEffect(() =>
() => {
if(shouldUseSharedVideoElement || videoPlayerRef.current !== currentVideoPlayerRef.current) {
useLayoutEffect(
() => () => {
if (shouldUseSharedVideoElement || videoPlayerRef.current !== currentVideoPlayerRef.current) {
return;
}
currentVideoPlayerRef.current = null;
}
, [currentVideoPlayerRef, shouldUseSharedVideoElement]);
},
[currentVideoPlayerRef, shouldUseSharedVideoElement],
);

useEffect(() => {
if (!isUploading || !videoPlayerRef.current) {
Expand Down Expand Up @@ -214,7 +215,7 @@ function BaseVideoPlayer({
}
return;
}

videoPlayerRef.current = currentVideoPlayerRef.current;
if (currentlyPlayingURL === url && newParentRef && 'appendChild' in newParentRef) {
newParentRef.appendChild(sharedElement as HTMLDivElement);
Expand Down

0 comments on commit 6cb3222

Please sign in to comment.