|
@@ -1,7 +1,6 @@
|
1
|
1
|
import React from 'react';
|
2
|
2
|
|
3
|
3
|
import {
|
4
|
|
- ActivityIndicator,
|
5
|
4
|
Image,
|
6
|
5
|
requireNativeComponent,
|
7
|
6
|
UIManager as NotTypedUIManager,
|
|
@@ -17,6 +16,8 @@ import {
|
17
|
16
|
defaultOriginWhitelist,
|
18
|
17
|
createOnShouldStartLoadWithRequest,
|
19
|
18
|
getViewManagerConfig,
|
|
19
|
+ defaultRenderError,
|
|
20
|
+ defaultRenderLoading,
|
20
|
21
|
} from './WebViewShared';
|
21
|
22
|
import {
|
22
|
23
|
WebViewErrorEvent,
|
|
@@ -38,12 +39,6 @@ const RNCWebView = requireNativeComponent(
|
38
|
39
|
) as typeof NativeWebViewAndroid;
|
39
|
40
|
const { resolveAssetSource } = Image;
|
40
|
41
|
|
41
|
|
-const defaultRenderLoading = () => (
|
42
|
|
- <View style={styles.loadingView}>
|
43
|
|
- <ActivityIndicator style={styles.loadingProgressBar} />
|
44
|
|
- </View>
|
45
|
|
-);
|
46
|
|
-
|
47
|
42
|
/**
|
48
|
43
|
* Renders a native WebView.
|
49
|
44
|
*/
|
|
@@ -228,6 +223,7 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
|
228
|
223
|
nativeConfig = {},
|
229
|
224
|
...otherProps
|
230
|
225
|
} = this.props;
|
|
226
|
+
|
231
|
227
|
let otherView = null;
|
232
|
228
|
|
233
|
229
|
if (this.state.viewState === 'LOADING') {
|
|
@@ -235,16 +231,18 @@ class WebView extends React.Component<AndroidWebViewProps, State> {
|
235
|
231
|
} else if (this.state.viewState === 'ERROR') {
|
236
|
232
|
const errorEvent = this.state.lastErrorEvent;
|
237
|
233
|
invariant(errorEvent != null, 'lastErrorEvent expected to be non-null');
|
238
|
|
- otherView
|
239
|
|
- = renderError
|
240
|
|
- && renderError(errorEvent.domain, errorEvent.code, errorEvent.description);
|
|
234
|
+ otherView = (renderError || defaultRenderError)(
|
|
235
|
+ errorEvent.domain,
|
|
236
|
+ errorEvent.code,
|
|
237
|
+ errorEvent.description,
|
|
238
|
+ );
|
241
|
239
|
} else if (this.state.viewState !== 'IDLE') {
|
242
|
240
|
console.error(
|
243
|
241
|
`RNCWebView invalid state encountered: ${this.state.viewState}`,
|
244
|
242
|
);
|
245
|
243
|
}
|
246
|
244
|
|
247
|
|
- const webViewStyles = [styles.container, style];
|
|
245
|
+ const webViewStyles = [styles.container, styles.webView, style];
|
248
|
246
|
if (
|
249
|
247
|
this.state.viewState === 'LOADING'
|
250
|
248
|
|| this.state.viewState === 'ERROR'
|