Open current webview url instead of start url

This commit is contained in:
Arnaud Vergnet 2020-09-23 19:08:09 +02:00
parent 4492debad9
commit 1639544810

View file

@ -66,6 +66,8 @@ class WebViewScreen extends React.PureComponent<PropsType> {
customPaddingFunction: null, customPaddingFunction: null,
}; };
currentUrl: string;
webviewRef: {current: null | WebView}; webviewRef: {current: null | WebView};
canGoBack: boolean; canGoBack: boolean;
@ -74,6 +76,7 @@ class WebViewScreen extends React.PureComponent<PropsType> {
super(props); super(props);
this.webviewRef = React.createRef(); this.webviewRef = React.createRef();
this.canGoBack = false; this.canGoBack = false;
this.currentUrl = props.url;
} }
/** /**
@ -222,8 +225,7 @@ class WebViewScreen extends React.PureComponent<PropsType> {
}; };
onOpenClicked = () => { onOpenClicked = () => {
const {url} = this.props; Linking.openURL(this.currentUrl);
Linking.openURL(url);
}; };
onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => { onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
@ -261,7 +263,8 @@ class WebViewScreen extends React.PureComponent<PropsType> {
onRefresh={this.onRefreshClicked} onRefresh={this.onRefreshClicked}
/> />
)} )}
onNavigationStateChange={(navState: {canGoBack: boolean}) => { onNavigationStateChange={(navState) => {
this.currentUrl = navState.url;
this.canGoBack = navState.canGoBack; this.canGoBack = navState.canGoBack;
}} }}
onMessage={props.onMessage} onMessage={props.onMessage}