Thibault Malbranche 5 年之前
父節點
當前提交
1148766747

+ 1
- 1
android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManager.java 查看文件

@@ -532,7 +532,7 @@ public class RNCWebViewManager extends SimpleViewManager<WebView> {
532 532
     view.getSettings().setJavaScriptEnabled(enabled);
533 533
   }
534 534
 
535
-  @ReactProp(name = "enableCache")
535
+  @ReactProp(name = "cacheEnabled")
536 536
   public void setCacheEnabled(WebView view, boolean enabled) {
537 537
     if (enabled) {
538 538
       Context ctx = view.getContext();

+ 5
- 6
docs/Reference.md 查看文件

@@ -48,7 +48,7 @@ This document lays out the current public properties and methods for the React N
48 48
 - [`incognito`](Reference.md#incognito)
49 49
 - [`allowFileAccess`](Reference.md#allowFileAccess)
50 50
 - [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
51
-- [`enableCache`](Reference.md#enableCache)
51
+- [`cacheEnabled`](Reference.md#cacheEnabled)
52 52
 - [`pagingEnabled`](Reference.md#pagingEnabled)
53 53
 - [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
54 54
 
@@ -361,9 +361,9 @@ Boolean value to enable third party cookies in the `WebView`. Used on Android Lo
361 361
 
362 362
 Sets the user-agent for the `WebView`. This will only work for iOS if you are using WKWebView, not UIWebView (see https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent).
363 363
 
364
-| Type   | Required | Platform |
365
-| ------ | -------- | -------- |
366
-| string | No       | Android, iOS WKWebView  |
364
+| Type   | Required | Platform               |
365
+| ------ | -------- | ---------------------- |
366
+| string | No       | Android, iOS WKWebView |
367 367
 
368 368
 ---
369 369
 
@@ -554,7 +554,7 @@ Sets whether the WebView should disable saving form data. The default value is `
554 554
 
555 555
 ---
556 556
 
557
-### `enableCache`
557
+### `cacheEnabled`
558 558
 
559 559
 Sets whether WebView & WKWebView should use browser caching.
560 560
 
@@ -582,7 +582,6 @@ A Boolean value that determines whether pressing on a link displays a preview of
582 582
 | ------- | -------- | -------- |
583 583
 | boolean | No       | iOS      |
584 584
 
585
-
586 585
 ## Methods
587 586
 
588 587
 ### `extraNativeComponentConfig()`

+ 1
- 1
ios/RNCWKWebView.h 查看文件

@@ -41,7 +41,7 @@
41 41
 @property (nonatomic, assign) BOOL incognito;
42 42
 @property (nonatomic, assign) BOOL useSharedProcessPool;
43 43
 @property (nonatomic, copy) NSString *userAgent;
44
-@property (nonatomic, assign) BOOL enableCache;
44
+@property (nonatomic, assign) BOOL cacheEnabled;
45 45
 @property (nonatomic, assign) BOOL allowsLinkPreview;
46 46
 
47 47
 - (void)postMessage:(NSString *)message;

+ 1
- 1
ios/RNCWKWebView.m 查看文件

@@ -83,7 +83,7 @@ static NSString *const MessageHanderName = @"ReactNative";
83 83
     WKWebViewConfiguration *wkWebViewConfig = [WKWebViewConfiguration new];
84 84
     if (_incognito) {
85 85
       wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
86
-    } else if (_enableCache) {
86
+    } else if (_cacheEnabled) {
87 87
       wkWebViewConfig.websiteDataStore = [WKWebsiteDataStore defaultDataStore];
88 88
     }
89 89
     if(self.useSharedProcessPool) {

+ 1
- 1
ios/RNCWKWebViewManager.m 查看文件

@@ -48,7 +48,7 @@ RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
48 48
 RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
49 49
 RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
50 50
 RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
51
-RCT_EXPORT_VIEW_PROPERTY(enableCache, BOOL)
51
+RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
52 52
 RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
53 53
 
54 54
 /**

+ 7
- 4
js/WebView.android.js 查看文件

@@ -17,7 +17,7 @@ import ReactNative, {
17 17
   StyleSheet,
18 18
   UIManager,
19 19
   View,
20
-  NativeModules
20
+  NativeModules,
21 21
 } from 'react-native';
22 22
 
23 23
 import invariant from 'fbjs/lib/invariant';
@@ -67,7 +67,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
67 67
     scalesPageToFit: true,
68 68
     allowFileAccess: false,
69 69
     saveFormDataDisabled: false,
70
-    enableCache: true,
70
+    cacheEnabled: true,
71 71
     androidHardwareAccelerationDisabled: false,
72 72
     originWhitelist: defaultOriginWhitelist,
73 73
   };
@@ -75,7 +75,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
75 75
   static isFileUploadSupported = async () => {
76 76
     // native implementation should return "true" only for Android 5+
77 77
     return NativeModules.RNCWebView.isFileUploadSupported();
78
-  }
78
+  };
79 79
 
80 80
   state = {
81 81
     viewState: this.props.startInLoadingState
@@ -152,10 +152,13 @@ class WebView extends React.Component<WebViewSharedProps, State> {
152 152
         injectedJavaScript={this.props.injectedJavaScript}
153 153
         userAgent={this.props.userAgent}
154 154
         javaScriptEnabled={this.props.javaScriptEnabled}
155
-        androidHardwareAccelerationDisabled={this.props.androidHardwareAccelerationDisabled}
155
+        androidHardwareAccelerationDisabled={
156
+          this.props.androidHardwareAccelerationDisabled
157
+        }
156 158
         thirdPartyCookiesEnabled={this.props.thirdPartyCookiesEnabled}
157 159
         domStorageEnabled={this.props.domStorageEnabled}
158 160
         messagingEnabled={typeof this.props.onMessage === 'function'}
161
+        cacheEnabled={this.props.cacheEnabled}
159 162
         onMessage={this.onMessage}
160 163
         overScrollMode={this.props.overScrollMode}
161 164
         contentInset={this.props.contentInset}

+ 7
- 7
js/WebView.ios.js 查看文件

@@ -133,7 +133,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
133 133
 
134 134
   static defaultProps = {
135 135
     useWebKit: true,
136
-    enableCache: true,
136
+    cacheEnabled: true,
137 137
     originWhitelist: defaultOriginWhitelist,
138 138
     useSharedProcessPool: true,
139 139
   };
@@ -141,7 +141,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
141 141
   static isFileUploadSupported = async () => {
142 142
     // no native implementation for iOS, depends only on permissions
143 143
     return true;
144
-  }
144
+  };
145 145
 
146 146
   state = {
147 147
     viewState: this.props.startInLoadingState
@@ -170,10 +170,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
170 170
       );
171 171
     }
172 172
 
173
-    if (
174
-      !this.props.useWebKit &&
175
-      this.props.incognito
176
-    ) {
173
+    if (!this.props.useWebKit && this.props.incognito) {
177 174
       console.warn(
178 175
         'The incognito property is not supported when useWebKit = false',
179 176
       );
@@ -255,13 +252,16 @@ class WebView extends React.Component<WebViewSharedProps, State> {
255 252
         bounces={this.props.bounces}
256 253
         scrollEnabled={this.props.scrollEnabled}
257 254
         pagingEnabled={this.props.pagingEnabled}
255
+        cacheEnabled={this.props.cacheEnabled}
258 256
         decelerationRate={decelerationRate}
259 257
         contentInset={this.props.contentInset}
260 258
         automaticallyAdjustContentInsets={
261 259
           this.props.automaticallyAdjustContentInsets
262 260
         }
263 261
         hideKeyboardAccessoryView={this.props.hideKeyboardAccessoryView}
264
-        allowsBackForwardNavigationGestures={this.props.allowsBackForwardNavigationGestures}
262
+        allowsBackForwardNavigationGestures={
263
+          this.props.allowsBackForwardNavigationGestures
264
+        }
265 265
         incognito={this.props.incognito}
266 266
         userAgent={this.props.userAgent}
267 267
         onLoadingStart={this._onLoadingStart}

+ 1
- 1
js/WebViewTypes.js 查看文件

@@ -491,7 +491,7 @@ export type WebViewSharedProps = $ReadOnly<{|
491 491
   /**
492 492
    * Should caching be enabled. Default is true.
493 493
    */
494
-  enableCache?: ?boolean,
494
+  cacheEnabled?: ?boolean,
495 495
 
496 496
   style?: ViewStyleProp,
497 497
   children: Node,