react-native: [WebView] in >= 0.7 crashes if wraps by another component

If WebView component in version 0.7 and above, wraps by another custom component, after couple of refreshes, crashes the react-native.

Here’s the code the sample code which causes crash after refresh the view couple of times.

'use strict';

var React = require('react-native');

var {
  AppRegistry,
  View,
  WebView,
  Component
} = React;

class CustomWebView extends Component {
  reload() {
    this.refs.internalWebView.reload();
  }
  render() {
    return (
      <WebView ref="internalWebView" {...this.props}/>
    );
  }
}

var Sample1 = React.createClass({
  componentDidMount() {
    this.refs.AWESOME.reload();
  },
  render: function() {
    var url = "http://google.com";
    return (
      <CustomWebView ref="AWESOME" url={url}/>
    );
  }
});

AppRegistry.registerComponent('Sample1', () => Sample1);

Here’s the error code

RCTWebViewManager.m:78
2015-07-15 15:29:12.885 Sample1[32006:13476976] *** 
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
 reason: 'Invalid view returned from registry, expecting RKWebView, got: (null)'

So it seems that viewRegistry contains only RCTRootContentView and React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]) returns a handler that doesn’t exists in viewRegistry.

** btw, It works perfectly fine on 0.6 **

Any thoughts?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20 (1 by maintainers)

Most upvoted comments

Hi there! This issue is being closed because it has been inactive for a while.

But don’t worry, it will live on with ProductPains! Check out its new home: https://productpains.com/post/react-native/webview-in-07-crashes-if-wraps-by-another-component

ProductPains helps the community prioritize the most important issues thanks to its voting feature. It is easy to use - just login with GitHub.

Also, if this issue is a bug, please consider sending a PR with a fix. We’re a small team and rely on the community for bug fixes of issues that don’t affect fb apps.