diff --git a/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx b/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx index 5f7cb872d..fc1fe0995 100644 --- a/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx +++ b/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx @@ -1,7 +1,6 @@ 'use client'; -import React from 'react'; import { Box } from '@/components/ui/box'; -import { useEffect } from 'react'; +import React, { useEffect } from 'react'; declare global { interface Window { @@ -12,70 +11,86 @@ declare global { const VadimStream = () => { useEffect(() => { - let player1: any = null; - let player2: any = null; - - // Load the IFrame Player API code asynchronously - const loadYouTubeAPI = () => { + // Only load the API if it hasn't been loaded yet + if (!document.getElementById('youtube-api')) { const tag = document.createElement('script'); + tag.id = 'youtube-api'; tag.src = 'https://www.youtube.com/iframe_api'; const firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode?.insertBefore(tag, firstScriptTag); - }; + } - // This function creates an