Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
React Native Change Webview URL

Hi guys after a function call and its eventual callback I have to change the webview url but the error prints that this.webview is undefined, this is my code. Into the function onMessage after I use postMessage from html I have to change the URL of the webview. Help me and I will never stop thanking you

export default class WevViewApp extends Component {
constructor( props ) {
    super( props );
    this.webView = null;
}


onMessage( event ) {
   if(registerToken){
       //change url of my webview
    }
}

render() {
    return (
        <View style={{flex: 1}}>
            <WebView
                ref={( webView ) => this.webView = webView}
                style={{flex: 1}}
                source={{uri: 'https://url.com/test123'}}
                javaScriptEnabled={true}
                injectedJavaScript={myInjectedJs}
                onMessage={this.onMessage}
            />
        </View>
    );
}

}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can update url using state

export default class WevViewApp extends Component {
    constructor(props) {
        super(props);
        this.webView = 'https://url.com/test123'; // you can define your on load URL
    }

    onMessage(event) {
        if (registerToken) {
            this.setState({
                webView: 'https://url.com/test123' // you just update URL here
            }) 
        }
    }

    render() {
        return (
            <View style={{ flex: 1 }}>
                <WebView
                    ref={(webView) => this.webView = webView}
                    style={{ flex: 1 }}
                    source={{ uri: this.state.webView }}
                    javaScriptEnabled={true}
                    injectedJavaScript={myInjectedJs}
                    onMessage={this.onMessage}
                />
            </View>
        );
    }
}


 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!