Skip to content

WebView.props.source.uri is never updated #14556

@savanthongvanh

Description

@savanthongvanh

WebView uri is never updated.

I'm loading a 3rd party chat client into a webview. The exit button of this this does history.go(-1)
which is not what I want but I have no control. My work around is to monitor the webview and call a function when they hit back. The problem is that I can't find out from the webview when they go back. WebView.props.source.uri never changes after it's loaded regardless of where you navigate to.

I would expect it to tell me the uri of the content currently loaded in the page.

Check out my snack that does this link

import React, { Component } from 'react';
import {WebView } from 'react-native';

var intervalHandle;

export default class App extends Component {

pingWebView (){
console.log(this.wView.props.source.uri);
}

render() {
return (
<WebView
ref={(wView)=>{this.wView = wView}}
source={{uri: "http://www.google.com"}}/>
);
}

componentWillUnmount(){
clearInterval(intervalHandle);
}

componentDidMount(){
console.log('mounted:');
console.log(this.wView);

intervalHandle = setInterval(this.pingWebView.bind(this), 1000);

}
}

Solution

Is this a bug? Is there a workaround?

Additional Information

  • React Native version: 0.34.1
  • Platform: iOS
  • Development Operating System: macos 10.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions