Skip to content

Commit

Permalink
Refactoring, logging
Browse files Browse the repository at this point in the history
  • Loading branch information
personalizedrefrigerator committed Dec 23, 2024
1 parent 442c918 commit 2a669b9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions packages/app-mobile/components/ExtendedWebView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
}, [props.hasPluginScripts]);

const [reloadCounter, setReloadCounter] = useState(0);
const refreshWebView = useCallback(() => {
// Reload the WebView after a brief delay. See https://github.com/react-native-webview/react-native-webview/issues/3524
shim.setTimeout(() => {
setReloadCounter(counter => counter + 1);
}, 150);
const refreshWebViewAfterCrash = useCallback(() => {
// Reload the WebView on crash. See https://github.com/react-native-webview/react-native-webview/issues/3524
logger.warn('Content process lost. Reloading the webview...');
setReloadCounter(counter => counter + 1);
}, []);

// - `setSupportMultipleWindows` must be `true` for security reasons:
Expand Down Expand Up @@ -132,8 +131,8 @@ const ExtendedWebView = (props: Props, ref: Ref<WebViewControl>) => {
onMessage={props.onMessage}
onError={props.onError ?? onError}
onLoadEnd={props.onLoadEnd}
onContentProcessDidTerminate={refreshWebView}
onRenderProcessGone={refreshWebView}
onContentProcessDidTerminate={refreshWebViewAfterCrash}
onRenderProcessGone={refreshWebViewAfterCrash}
decelerationRate='normal'
/>
);
Expand Down

0 comments on commit 2a669b9

Please sign in to comment.