Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"onNavigationStateChange" Unable to listen for route changes for single-page applications #200

Open
hzuhyb opened this issue Sep 30, 2018 · 2 comments

Comments

@hzuhyb
Copy link

hzuhyb commented Sep 30, 2018

I use onNavigationStateChange to monitor the change of URL:

onNavigationStateChange = (navState) => { console.log(navState) }

however, it will not be called if the page your WKWebView is trying to open is a SPA.

Environment

OS:  macOS Sierra 10.13.6
Node:  8.9.1
Yarn:  0.24.5
npm:  5.4.0

Packages: (wanted => installed)
react-native: 0.53.0
react: 16.3.1
react-native-wkwebview-reborn:  1.22.0

Steps to Reproduce

1.WKWebView opens https://eos.live and logs in
2.Click to jump to other pages

When the web page in WKWebView uses history.pushState () to change URL, onNavigationStateChange does not execute

Expected Behavior

onNavigationStateChange executes after each URL change

Actual Behavior

onNavigationStateChange does not execute every time URL changes

Reproducible Demo

<WKWebView
  onNavigationStateChange={this.onNavigationStateChange.bind(this)}
  source={{uri:"https://eos.live"}}
  allowsInlineMediaPlayback={true}
  domStorageEnabled={true}
  javaScriptEnabled={true}
  scalesPageToFit={false}
/>
@hzuhyb hzuhyb changed the title Unable to listen for route changes for single-page applications When the web page in WebView uses "history.pushState ()" to change URL, "onNavigationStateChange" does not execute Oct 4, 2018
@hzuhyb hzuhyb changed the title When the web page in WebView uses "history.pushState ()" to change URL, "onNavigationStateChange" does not execute "onNavigationStateChange" Unable to listen for route changes for single-page applications Oct 4, 2018
@yurnery
Copy link

yurnery commented Oct 27, 2018

I have the same problem, did you solved it?

@ColinChen2
Copy link

me too, any solution?
or merge pull request #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants