0

I am trying to call webview button click function on my own button click function but nothing seems to work. My code is similar to this

buttonClick = () => {
  
this.webview.injectJavaScript(`document.getElementById('webBtn').click()`);
}

redner(){

return(
<View>

 <WebView
            source={{uri: 'https://mywebsite.com'}}

          />

<TouchableOpacity onPress={() => this.buttonClick()}><Text> Click here </Text></TouchableOpacity>
</View>
)

}

I have tried the same Method with javascript It works Perfect there but I don't why its creating issues with the WebView in react Native . Any help would be Appreciated.

1 Answer 1

1

The ref of the WebView was not specified.

<WebView      
    ref={(ref)=>{this.webview=ref;}}
    source={{uri: 'https://mywebsite.com'}}    
/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.