The use of postMessage will lead to WebView onLoadStart run Twice,
See original GitHub issueIs 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}
/>
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:
- Created 6 years ago
- Reactions:10
- Comments:8
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
same issue, received duplicate message…
Closing in favor of new repo. Please keep discussing there 🚀