From 16395448103afaa5223fb86292e8552a5b1ab46c Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Wed, 23 Sep 2020 19:08:09 +0200 Subject: [PATCH] Open current webview url instead of start url --- src/components/Screens/WebViewScreen.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Screens/WebViewScreen.tsx b/src/components/Screens/WebViewScreen.tsx index 7a2feed..fe2c9b6 100644 --- a/src/components/Screens/WebViewScreen.tsx +++ b/src/components/Screens/WebViewScreen.tsx @@ -66,6 +66,8 @@ class WebViewScreen extends React.PureComponent { customPaddingFunction: null, }; + currentUrl: string; + webviewRef: {current: null | WebView}; canGoBack: boolean; @@ -74,6 +76,7 @@ class WebViewScreen extends React.PureComponent { super(props); this.webviewRef = React.createRef(); this.canGoBack = false; + this.currentUrl = props.url; } /** @@ -222,8 +225,7 @@ class WebViewScreen extends React.PureComponent { }; onOpenClicked = () => { - const {url} = this.props; - Linking.openURL(url); + Linking.openURL(this.currentUrl); }; onScroll = (event: NativeSyntheticEvent) => { @@ -261,7 +263,8 @@ class WebViewScreen extends React.PureComponent { onRefresh={this.onRefreshClicked} /> )} - onNavigationStateChange={(navState: {canGoBack: boolean}) => { + onNavigationStateChange={(navState) => { + this.currentUrl = navState.url; this.canGoBack = navState.canGoBack; }} onMessage={props.onMessage}