diff --git a/App.tsx b/App.tsx index 813e13b..4205be4 100644 --- a/App.tsx +++ b/App.tsx @@ -1,5 +1,7 @@ import React from 'react' import PdfReader from './src/' +import { WebViewErrorEvent } from 'react-native-webview/lib/WebViewTypes' +import { View, Text } from 'react-native' const base64 = 'data:application/pdf;base64,JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwog' + @@ -16,25 +18,44 @@ const base64 = 'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' + 'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G' -export default class App extends React.Component { - render() { +function App() { + const [error, setError] = React.useState( + undefined, + ) + if (error) { return ( - + > + + {error.nativeEvent.description} + + ) } + return ( + + ) } + +export default App diff --git a/src/index.tsx b/src/index.tsx index 3c16331..86134e8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -3,6 +3,10 @@ import * as CSS from 'csstype' import { View, ActivityIndicator, Platform, StyleSheet } from 'react-native' import { WebView } from 'react-native-webview' import * as FileSystem from 'expo-file-system' +import { + WebViewErrorEvent, + WebViewNavigationEvent, +} from 'react-native-webview/lib/WebViewTypes' const { cacheDirectory, @@ -147,9 +151,9 @@ interface Props { webviewProps?: WebView['props'] noLoader?: boolean customStyle?: CustomStyle - onLoad?(): void - onLoadEnd?(): void - onError?(): void + onLoad?(event: WebViewNavigationEvent): void + onLoadEnd?(event: WebViewNavigationEvent | WebViewErrorEvent): void + onError?(event: WebViewErrorEvent): void } interface State {