This commit is contained in:
Thibault Malbranche 2019-01-22 19:17:20 +01:00
parent 8ec7c16e5c
commit 1148766747
8 changed files with 24 additions and 22 deletions

View File

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

View File

@ -48,7 +48,7 @@ This document lays out the current public properties and methods for the React N
- [`incognito`](Reference.md#incognito)
- [`allowFileAccess`](Reference.md#allowFileAccess)
- [`saveFormDataDisabled`](Reference.md#saveFormDataDisabled)
- [`enableCache`](Reference.md#enableCache)
- [`cacheEnabled`](Reference.md#cacheEnabled)
- [`pagingEnabled`](Reference.md#pagingEnabled)
- [`allowsLinkPreview`](Reference.md#allowsLinkPreview)
@ -361,9 +361,9 @@ Boolean value to enable third party cookies in the `WebView`. Used on Android Lo
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).
| Type | Required | Platform |
| ------ | -------- | -------- |
| string | No | Android, iOS WKWebView |
| Type | Required | Platform |
| ------ | -------- | ---------------------- |
| string | No | Android, iOS WKWebView |
---
@ -554,7 +554,7 @@ Sets whether the WebView should disable saving form data. The default value is `
---
### `enableCache`
### `cacheEnabled`
Sets whether WebView & WKWebView should use browser caching.
@ -582,7 +582,6 @@ A Boolean value that determines whether pressing on a link displays a preview of
| ------- | -------- | -------- |
| boolean | No | iOS |
## Methods
### `extraNativeComponentConfig()`

View File

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

View File

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

View File

@ -48,7 +48,7 @@ RCT_EXPORT_VIEW_PROPERTY(allowsBackForwardNavigationGestures, BOOL)
RCT_EXPORT_VIEW_PROPERTY(incognito, BOOL)
RCT_EXPORT_VIEW_PROPERTY(pagingEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(userAgent, NSString)
RCT_EXPORT_VIEW_PROPERTY(enableCache, BOOL)
RCT_EXPORT_VIEW_PROPERTY(cacheEnabled, BOOL)
RCT_EXPORT_VIEW_PROPERTY(allowsLinkPreview, BOOL)
/**

View File

@ -17,7 +17,7 @@ import ReactNative, {
StyleSheet,
UIManager,
View,
NativeModules
NativeModules,
} from 'react-native';
import invariant from 'fbjs/lib/invariant';
@ -67,7 +67,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
scalesPageToFit: true,
allowFileAccess: false,
saveFormDataDisabled: false,
enableCache: true,
cacheEnabled: true,
androidHardwareAccelerationDisabled: false,
originWhitelist: defaultOriginWhitelist,
};
@ -75,7 +75,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
static isFileUploadSupported = async () => {
// native implementation should return "true" only for Android 5+
return NativeModules.RNCWebView.isFileUploadSupported();
}
};
state = {
viewState: this.props.startInLoadingState
@ -152,10 +152,13 @@ class WebView extends React.Component<WebViewSharedProps, State> {
injectedJavaScript={this.props.injectedJavaScript}
userAgent={this.props.userAgent}
javaScriptEnabled={this.props.javaScriptEnabled}
androidHardwareAccelerationDisabled={this.props.androidHardwareAccelerationDisabled}
androidHardwareAccelerationDisabled={
this.props.androidHardwareAccelerationDisabled
}
thirdPartyCookiesEnabled={this.props.thirdPartyCookiesEnabled}
domStorageEnabled={this.props.domStorageEnabled}
messagingEnabled={typeof this.props.onMessage === 'function'}
cacheEnabled={this.props.cacheEnabled}
onMessage={this.onMessage}
overScrollMode={this.props.overScrollMode}
contentInset={this.props.contentInset}

View File

@ -133,7 +133,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
static defaultProps = {
useWebKit: true,
enableCache: true,
cacheEnabled: true,
originWhitelist: defaultOriginWhitelist,
useSharedProcessPool: true,
};
@ -141,7 +141,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
static isFileUploadSupported = async () => {
// no native implementation for iOS, depends only on permissions
return true;
}
};
state = {
viewState: this.props.startInLoadingState
@ -170,10 +170,7 @@ class WebView extends React.Component<WebViewSharedProps, State> {
);
}
if (
!this.props.useWebKit &&
this.props.incognito
) {
if (!this.props.useWebKit && this.props.incognito) {
console.warn(
'The incognito property is not supported when useWebKit = false',
);
@ -255,13 +252,16 @@ class WebView extends React.Component<WebViewSharedProps, State> {
bounces={this.props.bounces}
scrollEnabled={this.props.scrollEnabled}
pagingEnabled={this.props.pagingEnabled}
cacheEnabled={this.props.cacheEnabled}
decelerationRate={decelerationRate}
contentInset={this.props.contentInset}
automaticallyAdjustContentInsets={
this.props.automaticallyAdjustContentInsets
}
hideKeyboardAccessoryView={this.props.hideKeyboardAccessoryView}
allowsBackForwardNavigationGestures={this.props.allowsBackForwardNavigationGestures}
allowsBackForwardNavigationGestures={
this.props.allowsBackForwardNavigationGestures
}
incognito={this.props.incognito}
userAgent={this.props.userAgent}
onLoadingStart={this._onLoadingStart}

View File

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