Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/open-olives-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-native-youtube-bridge": patch
---

fix(web): prevent player rerender when onError is not wrapped with useCallback
5 changes: 3 additions & 2 deletions src/hooks/useYoutubePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const useYouTubePlayer = (config: YoutubePlayerConfig) => {
coreRef.current = null;
}, []);

// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
// biome-ignore lint/correctness/useExhaustiveDependencies: initialize only once
useEffect(() => {
if (!coreRef.current) {
coreRef.current = new YouTubePlayerCore({
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down