react-native-webview.git

WKWebView.ios.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. *
  7. * @format
  8. * @flow
  9. * @providesModule WKWebView
  10. */
  11. import React from 'react';
  12. import { requireNativeComponent } from 'react-native';
  13. const RCTWKWebView = requireNativeComponent('RCTWKWebView');
  14. type RCTWKWebViewProps = {
  15. allowsInlineMediaPlayback?: boolean,
  16. mediaPlaybackRequiresUserAction?: boolean,
  17. dataDetectorTypes?: boolean,
  18. };
  19. class WKWebView extends React.Component<RCTWKWebViewProps> {
  20. componentWillReceiveProps(nextProps: RCTWKWebViewProps) {
  21. this.showRedboxOnPropChanges(nextProps, 'allowsInlineMediaPlayback');
  22. this.showRedboxOnPropChanges(nextProps, 'mediaPlaybackRequiresUserAction');
  23. this.showRedboxOnPropChanges(nextProps, 'dataDetectorTypes');
  24. }
  25. showRedboxOnPropChanges(nextProps: RCTWKWebViewProps, propName: string) {
  26. if (this.props[propName] !== nextProps[propName]) {
  27. console.error(`Changes to property ${propName} do nothing after the initial render.`);
  28. }
  29. }
  30. render() {
  31. return <RCTWKWebView {...this.props} />;
  32. }
  33. }
  34. module.exports = WKWebView;