mirror of
https://github.com/status-im/react-native.git
synced 2025-01-29 10:45:04 +00:00
1af17f1648
Summary: When text is rendered in `WKWebView` WebKit component, the component itself can detect things like phone numbers, flight numbers, links, etc. and render them with additional functionality. For example, when the text `apple.com` is detected, if the `link` data detector type is enabled, the web view will actually render a link that takes the user to the Apple home page. In this diff, I implement the `dataDetectorTypes` prop. The data detector types supported are: 1. phoneNumber 1. link 1. address 1. calendarEvent 1. trackingNumber 1. flightNumber 1. lookupSuggestion These enums are documented in the [[ https://developer.apple.com/documentation/webkit/wkdatadetectortypes | WKDataDetectorTypes docs ]]. Reviewed By: shergin Differential Revision: D6392546 fbshipit-source-id: 4dd373f0ac52f898163cd959eeef6672e55b42a6
43 lines
1.2 KiB
JavaScript
43 lines
1.2 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
|
|
*/
|
|
|
|
const React = require('react');
|
|
|
|
const requireNativeComponent = require('requireNativeComponent');
|
|
|
|
const RCTWKWebView = requireNativeComponent('RCTWKWebView');
|
|
|
|
type RCTWKWebViewProps = {
|
|
allowsInlineMediaPlayback?: boolean,
|
|
mediaPlaybackRequiresUserAction?: boolean,
|
|
dataDetectorTypes?: boolean,
|
|
};
|
|
|
|
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;
|