mirror of
https://github.com/status-im/react-native-webview.git
synced 2025-02-23 17:28:37 +00:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
* @providesModule WKWebView
|
|
*/
|
|
|
|
import React from 'react';
|
|
|
|
import { requireNativeComponent } from 'react-native';
|
|
|
|
import type {DataDetectorTypes} from './WebViewTypes';
|
|
|
|
const RCTWKWebView = requireNativeComponent('RCTWKWebView');
|
|
|
|
type RCTWKWebViewProps = $ReadOnly<{|
|
|
allowsInlineMediaPlayback?: ?boolean,
|
|
mediaPlaybackRequiresUserAction?: ?boolean,
|
|
dataDetectorTypes?:
|
|
| ?DataDetectorTypes
|
|
| $ReadOnlyArray<DataDetectorTypes>,
|
|
|}>;
|
|
|
|
class WKWebView extends React.Component<RCTWKWebViewProps> {
|
|
componentWillReceiveProps(nextProps: RCTWKWebViewProps) {
|
|
this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
|
|
this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
|
|
this.showRedboxOnPropChanges(nextProps, 'dataDetectorTypes');
|
|
}
|
|
|
|
showRedboxOnPropChanges(nextProps: RCTWKWebViewProps, propName: string) {
|
|
if (this.props[propName] !== nextProps[propName]) {
|
|
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return <RCTWKWebView {...this.props} />;
|
|
}
|
|
}
|
|
|
|
module.exports = WKWebView;
|