diff --git a/.changeset/open-olives-cry.md b/.changeset/open-olives-cry.md new file mode 100644 index 0000000..c40470f --- /dev/null +++ b/.changeset/open-olives-cry.md @@ -0,0 +1,5 @@ +--- +"react-native-youtube-bridge": patch +--- + +fix(web): prevent player rerender when onError is not wrapped with useCallback diff --git a/src/hooks/useYoutubePlayer.ts b/src/hooks/useYoutubePlayer.ts index fbc3d51..ffc9b52 100644 --- a/src/hooks/useYoutubePlayer.ts +++ b/src/hooks/useYoutubePlayer.ts @@ -27,7 +27,7 @@ const useYouTubePlayer = (config: YoutubePlayerConfig) => { coreRef.current = null; }, []); - // biome-ignore lint/correctness/useExhaustiveDependencies: + // biome-ignore lint/correctness/useExhaustiveDependencies: initialize only once useEffect(() => { if (!coreRef.current) { coreRef.current = new YouTubePlayerCore({ @@ -46,6 +46,7 @@ const useYouTubePlayer = (config: YoutubePlayerConfig) => { return cleanup; }, []); + // biome-ignore lint/correctness/useExhaustiveDependencies: update only playerVars useEffect(() => { const initialize = async () => { if (!containerRef.current) { @@ -81,7 +82,7 @@ const useYouTubePlayer = (config: YoutubePlayerConfig) => { }; initialize(); - }, [videoId, startTime, endTime, autoplay, controls, loop, muted, playsinline, rel, origin, onError]); + }, [videoId, startTime, endTime, autoplay, controls, loop, muted, playsinline, rel, origin]); useEffect(() => { if (isReady && videoId && coreRef.current) {