diff --git a/packages/react-youtube/src/YouTube.tsx b/packages/react-youtube/src/YouTube.tsx index 55135a7..d217d9c 100644 --- a/packages/react-youtube/src/YouTube.tsx +++ b/packages/react-youtube/src/YouTube.tsx @@ -48,9 +48,7 @@ function filterResetOptions(opts: Options = {}) { * those. */ function shouldResetPlayer(prevProps: YouTubeProps, props: YouTubeProps) { - return ( - prevProps.videoId !== props.videoId || !isEqual(filterResetOptions(prevProps.opts), filterResetOptions(props.opts)) - ); + return !isEqual(filterResetOptions(prevProps.opts), filterResetOptions(props.opts)); } /** diff --git a/packages/react-youtube/src/Youtube.test.tsx b/packages/react-youtube/src/Youtube.test.tsx index eda2e77..5b2409a 100644 --- a/packages/react-youtube/src/Youtube.test.tsx +++ b/packages/react-youtube/src/Youtube.test.tsx @@ -148,18 +148,13 @@ describe('YouTube', () => { expect(playerMock.destroy).toHaveBeenCalled(); }); - it('should create and bind a new YouTube player when props.videoId, playerVars.autoplay, playerVars.start, or playerVars.end change', async () => { + it('should not create and bind a new YouTube player when only props.videoId changes', async () => { const { rerender } = render( , ); @@ -170,19 +165,12 @@ describe('YouTube', () => { opts={{ width: '480px', height: '360px', - playerVars: { - autoplay: 1, // changed, does not force destroy & rebind - start: 10, // changed, does not force destroy & rebind - end: 20, // changed, does not force destroy & rebind - }, }} />, ); - // player is destroyed & rebound, despite the changes - expect(playerMock.destroy).toHaveBeenCalled(); - // and the video is updated - await waitFor(() => expect(playerMock.loadVideoById).toHaveBeenCalled()); + // player is not destroyed & rebound, despite the change + expect(playerMock.destroy).not.toHaveBeenCalled(); }); it('should not create and bind a new YouTube player when only playerVars.autoplay, playerVars.start, or playerVars.end change', () => {