From 63f600d1dd2664eb7ef5728c69e47fc79043b034 Mon Sep 17 00:00:00 2001 From: Sanchitv3 Date: Thu, 16 Jan 2025 12:53:15 +0530 Subject: [PATCH 1/2] fix: fixed ytPlayer issue in Vadim's Stream --- .../nativewind/VadimStream.tsx | 110 ++++++++++++------ 1 file changed, 73 insertions(+), 37 deletions(-) diff --git a/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx b/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx index 5f7cb872d..c46fcbf6d 100644 --- a/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx +++ b/example/storybook-nativewind/src/extra-components/nativewind/VadimStream.tsx @@ -1,6 +1,11 @@ 'use client'; import React from 'react'; -import { Box } from '@/components/ui/box'; +import { Box } from '@/components/ui/box/'; +import { Heading } from '@/components/ui/heading/'; +import { Text } from '@/components/ui/text/'; +import { VStack } from '@/components/ui/vstack/'; +import { HStack } from '@/components/ui/hstack/'; +import { Span } from '@expo/html-elements'; import { useEffect } from 'react'; declare global { @@ -12,70 +17,101 @@ 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