简体   繁体   中英

Is there a way to use webview.goBack and navigation.goBack using the same button in react native webview?

I'm working on a react native app which uses a webview. I want to use a single back button to navigate within the webview as well as to exit the webview and return to the homescreen of the app. I'm aware of canGoBack property but the onNavigationStateChange function is fired only when navigating to a link in another domain. Any way i can can achieve the same functionality when navigating between screens in the same domain?

On same button click check

if (webview.goBack()){
  // if web view has something to go back use it
}else{
navigation.goBack()
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM