Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda