Skip to content

Commit 752c81e

Browse files
committed
Combine onShouldStartLoadWithRequest event-based and synchronous methods into one
1 parent dbc27ba commit 752c81e

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

src/WebView.android.tsx

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -278,18 +278,13 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
278278
};
279279

280280
onShouldStartLoadWithRequestCallback = (
281-
shouldStart: boolean,
282-
_: string,
283-
lockIdentifier: number,
284-
) => {
285-
NativeModules.RNCWebView.onShouldStartLoadWithRequestCallback(shouldStart, lockIdentifier);
286-
};
287-
288-
legacyOnShouldStartLoadWithRequestCallback = (
289281
shouldStart: boolean,
290282
url: string,
283+
lockIdentifier?: number,
291284
) => {
292-
if (shouldStart) {
285+
if (lockIdentifier) {
286+
NativeModules.RNCWebView.onShouldStartLoadWithRequestCallback(shouldStart, lockIdentifier);
287+
} else if (shouldStart) {
293288
UIManager.dispatchViewManagerCommand(
294289
this.getWebViewHandle(),
295290
this.getCommands().loadUrl,
@@ -353,13 +348,6 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
353348
onShouldStartLoadWithRequestProp,
354349
);
355350

356-
const onShouldStartLoadWithRequest = createOnShouldStartLoadWithRequest(
357-
this.legacyOnShouldStartLoadWithRequestCallback,
358-
// casting cause it's in the default props
359-
originWhitelist as readonly string[],
360-
onShouldStartLoadWithRequestProp,
361-
);
362-
363351
const webView = (
364352
<NativeWebView
365353
key="webViewKey"
@@ -373,7 +361,7 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
373361
onHttpError={this.onHttpError}
374362
onRenderProcessGone={this.onRenderProcessGone}
375363
onMessage={this.onMessage}
376-
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
364+
onShouldStartLoadWithRequest={this.onShouldStartLoadWithRequest}
377365
ref={this.webViewRef}
378366
// TODO: find a better way to type this.
379367
source={resolveAssetSource(source as ImageSourcePropType)}

0 commit comments

Comments
 (0)