React-native-webview: Webview does not redirect to domain from subdomain

Created on 24 Feb 2020  路  3Comments  路  Source: react-native-webview/react-native-webview

Bug description:
I have a webview with URL Bar which allows users to input url to navigate to.

Problem is that webview prevents to redirect back to the domain from subdomain(or routes).
The wording is not clear, so let me explain with example.

Consider https://stackoverflow.com.

  1. User enters 'https://stackoverflow.com'.
  2. User navigates to url 'https://stackoverflow.com/users' through tapping top left hamburger menu and then tapping 'Users' (not by user input to url bar)
  3. now, user wants to navigate back to 'https://stackoverflow.com/', but this time by user input to the url bar (just by deleting the word 'users')
  4. nothing happens. All of the navigation callbacks(such as onLoadStart, onNavigationStatechange, etc..) are not called at all.

This is the behavior that happens when we try to redirect to the same url that we are currently in, i.e. https://stackoverflow.com/ to https://stackoverflow.com/.

I've already checked that the state in 'source' prop correctly changes to 'https://stackoverflow.com/' from 'https://stackoverflow.com/users'

I think webview is recognizing those two as same url somehow internally?

Expected behavior:
Navigate to the expected url.

Screenshots/Videos:

image

image

image

Environment:

  • OS: MacOs
  • OS version: 10.14.6
  • react-native version: 0.61.5
  • react-native-webview version: 8.1.2
bug report

Most helpful comment

hi @gregoryfm, i found out that this issue occurs when the webview loads SPA. here's a guide on how to get SPA to play nicely with react-native-webview: https://medium.com/@tanjohnny/webview-of-your-spa-in-react-native-a06b0aa2e85d

hope that helps!

All 3 comments

Hi @panda0603, I'm currently facing this issue on Android (iOS is fine. I'm on the latest version) as well, where the navigation callbacks are not triggered when navigating to pages within the same domain. Did you manage to find a workaround for this issue?

@panda0603 @ijasm did you find the solution?
I'm facing the same issue on Android.

hi @gregoryfm, i found out that this issue occurs when the webview loads SPA. here's a guide on how to get SPA to play nicely with react-native-webview: https://medium.com/@tanjohnny/webview-of-your-spa-in-react-native-a06b0aa2e85d

hope that helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AdamZaczek picture AdamZaczek  路  3Comments

jayshah123 picture jayshah123  路  3Comments

codesinghanoop picture codesinghanoop  路  3Comments

TheMakerOleguch picture TheMakerOleguch  路  3Comments

ranshine picture ranshine  路  3Comments