Skip to content

Commit 4ef2c67

Browse files
committed
partially allow source prop to be overridden
1 parent b2ee3ef commit 4ef2c67

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/YoutubeIframe.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,11 @@ const YoutubeIframe = (props, ref) => {
168168
return (
169169
<View style={{height, width}}>
170170
<WebView
171-
ref={webViewRef}
172171
originWhitelist={['*']}
173-
onMessage={onWebMessage}
174172
allowsInlineMediaPlayback
175173
style={[styles.webView, webViewStyle]}
176174
mediaPlaybackRequiresUserAction={false}
177175
allowsFullscreenVideo={!initialPlayerParams?.preventFullScreen}
178-
source={{
179-
html: MAIN_SCRIPT(
180-
videoId,
181-
playList,
182-
initialPlayerParams,
183-
allowWebViewZoom,
184-
contentScale,
185-
),
186-
}}
187176
userAgent={
188177
forceAndroidAutoplay
189178
? Platform.select({android: CUSTOM_USER_AGENT, ios: ''})
@@ -193,7 +182,27 @@ const YoutubeIframe = (props, ref) => {
193182
return request.mainDocumentURL === 'about:blank';
194183
}}
195184
bounces={false}
185+
// props above this are override-able
186+
187+
// --
196188
{...webViewProps}
189+
// --
190+
191+
//add props that should not be allowed to be overridden below
192+
ref={webViewRef}
193+
onMessage={onWebMessage}
194+
source={{
195+
// partially allow source to be overridden
196+
...webViewProps.source,
197+
method: 'GET',
198+
html: MAIN_SCRIPT(
199+
videoId,
200+
playList,
201+
initialPlayerParams,
202+
allowWebViewZoom,
203+
contentScale,
204+
),
205+
}}
197206
/>
198207
</View>
199208
);

0 commit comments

Comments
 (0)