From 217f43166d97d485dbcdb64c261c72ef2aa7817f Mon Sep 17 00:00:00 2001 From: saseungmin Date: Sun, 22 Jun 2025 17:25:11 +0900 Subject: [PATCH] fix: override webview source props (header, method, body) --- .changeset/clear-pigs-stop.md | 5 +++++ example/src/App.tsx | 3 +++ src/YoutubePlayer.tsx | 6 +++++- src/types/youtube.ts | 5 ++++- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .changeset/clear-pigs-stop.md diff --git a/.changeset/clear-pigs-stop.md b/.changeset/clear-pigs-stop.md new file mode 100644 index 0000000..7b16694 --- /dev/null +++ b/.changeset/clear-pigs-stop.md @@ -0,0 +1,5 @@ +--- +"react-native-youtube-bridge": patch +--- + +fix: override webview source props (method, body, header) diff --git a/example/src/App.tsx b/example/src/App.tsx index 6e8e5ec..0761275 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -182,6 +182,9 @@ function App() { rel: false, muted: true, }} + webViewProps={{ + renderToHardwareTextureAndroid: true, + }} progressInterval={progressInterval} onReady={handleReady} onStateChange={handleStateChange} diff --git a/src/YoutubePlayer.tsx b/src/YoutubePlayer.tsx index 8c2ad94..c492a82 100644 --- a/src/YoutubePlayer.tsx +++ b/src/YoutubePlayer.tsx @@ -268,7 +268,11 @@ const YoutubePlayer = forwardRef( {...webViewProps} ref={webViewRef} javaScriptEnabled - source={useInlineHtml ? { html: createPlayerHTML(), baseUrl: webViewBaseUrl } : { uri: webViewUrl }} + source={ + useInlineHtml + ? { html: createPlayerHTML(), baseUrl: webViewBaseUrl } + : { ...(webViewProps?.source ?? {}), uri: webViewUrl } + } onMessage={handleMessage} onError={(error) => { console.error('WebView error:', error); diff --git a/src/types/youtube.ts b/src/types/youtube.ts index b01d780..67fa768 100644 --- a/src/types/youtube.ts +++ b/src/types/youtube.ts @@ -1,6 +1,7 @@ import type { CSSProperties } from 'react'; import type { DimensionValue, StyleProp, ViewStyle } from 'react-native'; import type { WebViewProps } from 'react-native-webview'; +import type { WebViewSourceUri } from 'react-native-webview/lib/WebViewTypes'; export type YoutubePlayerVars = { /** @@ -84,7 +85,9 @@ export type YoutubePlayerProps = { /** * @platform ios, android */ - webViewProps?: Omit; + webViewProps?: Omit & { + source?: Omit; + }; /** * @platform web */