question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The use of postMessage will lead to WebView onLoadStart run Twice,

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

OS: macOS Sierra 10.12.6 Node: v7.10.0 Yarn: 0.27.5 npm: 4.2.0 Watchman: 4.7.0 Xcode: Xcode Version 9.1 beta (9B37) Android Studio: 2.3 react-native: 0.48.4 react: 16.0.0-alpha.12 Target Platform: iOS (8-11.1) android(4.4.4-8.0)

Steps to Reproduce

messtest = e => {
  const message = e.nativeEvent.data
  alert(message)
}
<WebView
  ref={w => this.webview = w}
  source={{uri:jumpUrl}}
  onMessage={this.messtest}
  domStorageEnabled={true}
  javaScriptEnabled={true}
  startInLoadingState={true}
  dataDetectorTypes="none"
  onLoadEnd={()=>{
    console.log('load end... onLoadEnd function');
  }}
  onLoadStart={()=>{
    console.log('load start..');
  }}
  renderLoading={this._renderLoading}
  //onNavigationStateChange={this.onNavigationStateChange}
/>

image

Expected Behavior

LoadStart should be executed before loadEnd,As you can see from the diagram, load end... re executes load start , and then does not execute load end, which causes the state to be updated. It has always been load start

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:10
  • Comments:8

github_iconTop GitHub Comments

5reactions
jojolcommented, Nov 21, 2017

same issue, received duplicate message…

0reactions
Titozzzcommented, Sep 26, 2018

Closing in favor of new repo. Please keep discussing there 🚀

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native WebView postMessage does not work
Setting this property will inject a postMessage global into your webview, but will still call pre-existing values of postMessage. Maybe this is ......
Read more >
Reactnativewebview Running Twice - ADocLib
OnLoadStart time to start loading callback; In onMessage webView internal Web ... The use of postMessage will lead to WebView onLoadStart run Twice...
Read more >
react-native-wkwebview-reborn - npm
React Native comes with WebView component, which uses UIWebView on iOS. This component uses WKWebView introduced in iOS 8 with all the ...
Read more >
InAppWebView: the real power of WebViews in Flutter
It can be used to run a WebView in background without attaching an InAppWebView to the widget tree. InAppBrowser: in-app browser using ...
Read more >
Fixing React Native WebView's postMessage for iOS
Then just use the new WebView component as you would the React Native ... Each postMessage event will fire the navigation state change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found