React Native WebView OnError

Just started with React Native. I made a little app that has access to a shared google drive. I decided to load it in WebView vs try to integrate with Google Drive API. I’m running into an issue with the onError property.

I can’t get the onError to capture the error. I’m trying to catch a load / network error and give the user a way to retry the page load. I made the WebView as a component. It looks like this. Any thoughts ?

import React from “react”;
import { WebView } from ‘react-native-webview’;
import { StyleSheet } from ‘react-native’;
import Constants from ‘expo-constants’;

class GetWeb extends React.Component{
render()

{ return (

    <WebView 

      style={styles.container}

      source={{ uri: '[google drive URI]' }}

      onError={(event) => {

        Alert.alert('load error',  '', [

            {

                text: 'Cancel',

            },

            {

                text: 'Retry',

                onPress: () => {

                    this.webView.reload();

                },

            },

        ]);

    }}

    />

)

}

}

const styles = StyleSheet.create({

container: {

  flex: 1,

  marginTop: Constants.statusBarHeight,

},

});

export default GetWeb;