react-native-webview crashes application when invoked
Seems like a bug with the new version, but as per this doc ( https://github.com/react-native-community/react-native-webview/issues/1312 ) it can be solved as follows
first install react-native-get-random-values, then import it at the top of your file
import 'react-native-get-random-values';
import React, { Component } from 'react';
import { WebView } from 'react-native-webview';
import {
StyleSheet,
View,
Text,
} from 'react-native';
export default class MyWeb extends Component {
render() {
return (
<View style={{ backgroundColor: 'blue',flex: 1 }}>
<WebView
source={{ uri: 'https://url.ngrok.io' }}
style={{ marginTop: 20, }}
/>
</View>
);
}
}
Install 'react-native-get-random-values' package.
Then add "import 'react-native-get-random-values'" at the entry file of your react native app as follows. Like index.js when the application created using React Native CLI
import 'react-native-get-random-values';
import React, {Component} from 'react';
import { WebView } from 'react-native-webview';
class MyWebComponent extends Component {
render() {
return <WebView source={{ uri: 'https://reactnative.dev/' }} />;
}
}
I've got the same error after upgrade of react-native-webview to version 9.1.3. After downgrade to 9.1.1 the error disapear. Version 9.1.2 is not checked.
Update on 2020.04.12. In version 9.1.4 the error exists also. With 'react-native-get-random-values' as described below all works. I'm using CLI version.
Update on 2020.04.24. In version 9.2.2 the error is corrected. I removed package 'react-native-get-random-values' and all works fine.