Browse Source

Open current webview url instead of start url

Arnaud Vergnet 1 year ago
parent
commit
1639544810
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      src/components/Screens/WebViewScreen.tsx

+ 6
- 3
src/components/Screens/WebViewScreen.tsx View File

@@ -66,6 +66,8 @@ class WebViewScreen extends React.PureComponent<PropsType> {
66 66
     customPaddingFunction: null,
67 67
   };
68 68
 
69
+  currentUrl: string;
70
+
69 71
   webviewRef: {current: null | WebView};
70 72
 
71 73
   canGoBack: boolean;
@@ -74,6 +76,7 @@ class WebViewScreen extends React.PureComponent<PropsType> {
74 76
     super(props);
75 77
     this.webviewRef = React.createRef();
76 78
     this.canGoBack = false;
79
+    this.currentUrl = props.url;
77 80
   }
78 81
 
79 82
   /**
@@ -222,8 +225,7 @@ class WebViewScreen extends React.PureComponent<PropsType> {
222 225
   };
223 226
 
224 227
   onOpenClicked = () => {
225
-    const {url} = this.props;
226
-    Linking.openURL(url);
228
+    Linking.openURL(this.currentUrl);
227 229
   };
228 230
 
229 231
   onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
@@ -261,7 +263,8 @@ class WebViewScreen extends React.PureComponent<PropsType> {
261 263
             onRefresh={this.onRefreshClicked}
262 264
           />
263 265
         )}
264
-        onNavigationStateChange={(navState: {canGoBack: boolean}) => {
266
+        onNavigationStateChange={(navState) => {
267
+          this.currentUrl = navState.url;
265 268
           this.canGoBack = navState.canGoBack;
266 269
         }}
267 270
         onMessage={props.onMessage}

Loading…
Cancel
Save