2018-09-08 10:42:02 -07:00
|
|
|
/**
|
|
|
|
* 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';
|
|
|
|
|
2018-09-10 12:13:20 -06:00
|
|
|
import type {DataDetectorTypes} from './WebViewTypes';
|
|
|
|
|
2018-09-19 00:46:19 +02:00
|
|
|
const RNCWKWebView = requireNativeComponent('RNCWKWebView');
|
2018-09-08 10:42:02 -07:00
|
|
|
|
2018-09-19 00:46:19 +02:00
|
|
|
type RNCWKWebViewProps = $ReadOnly<{|
|
2018-09-10 12:13:20 -06:00
|
|
|
allowsInlineMediaPlayback?: ?boolean,
|
|
|
|
mediaPlaybackRequiresUserAction?: ?boolean,
|
|
|
|
dataDetectorTypes?:
|
|
|
|
| ?DataDetectorTypes
|
|
|
|
| $ReadOnlyArray<DataDetectorTypes>,
|
|
|
|
|}>;
|
2018-09-09 22:40:32 -06:00
|
|
|
|
2018-09-19 00:46:19 +02:00
|
|
|
class WKWebView extends React.Component<RNCWKWebViewProps> {
|
|
|
|
componentWillReceiveProps(nextProps: RNCWKWebViewProps) {
|
2018-09-08 10:42:02 -07:00
|
|
|
this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
|
|
|
|
this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
|
|
|
|
this.showRedboxOnPropChanges(nextProps, 'dataDetectorTypes');
|
|
|
|
}
|
|
|
|
|
2018-09-19 00:46:19 +02:00
|
|
|
showRedboxOnPropChanges(nextProps: RNCWKWebViewProps, propName: string) {
|
2018-09-08 10:42:02 -07:00
|
|
|
if (this.props[propName] !== nextProps[propName]) {
|
|
|
|
console.error(`Changes to property ${propName} do nothing after the initial render.`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2018-09-19 00:46:19 +02:00
|
|
|
return <RNCWKWebView {...this.props} />;
|
2018-09-08 10:42:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = WKWebView;
|