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

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

Closed
TrustDec opened this issue Oct 26, 2017 · 8 comments
Closed

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

TrustDec opened this issue Oct 26, 2017 · 8 comments
Labels
Component: WebView Related to the WebView component. Resolution: Locked This issue was locked by the bot.

Comments

@TrustDec
Copy link

TrustDec commented Oct 26, 2017

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

@jojol
Copy link

jojol commented Nov 21, 2017

same issue, received duplicate message...

@jayshah123
Copy link
Contributor

Yes, post message seems to change location/url of the window and hence resulting in multiple calls to onLoad, is there any way to avoid this?

@hramos hramos added the Component: WebView Related to the WebView component. label Mar 8, 2018
@reedspool
Copy link

I do not have an answer, but I have found offending code which proves the assumptions https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java#L578

@stale
Copy link

stale bot commented Jul 24, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 24, 2018
@TrustDec
Copy link
Author

Unresolved, the problem still exists

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jul 29, 2018
@tedscape
Copy link

The problem still exists.

@jamonholmgren
Copy link
Collaborator

This issue has been migrated to react-native-webview/react-native-webview#9 and can be closed.

@Titozzz
Copy link
Collaborator

Titozzz commented Sep 26, 2018

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

@Titozzz Titozzz closed this as completed Sep 26, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Dec 11, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: WebView Related to the WebView component. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

9 participants