From 9a31fa5fd62fa101b2a76c69b56248d7f5ba9876 Mon Sep 17 00:00:00 2001 From: Eli White Date: Wed, 14 Aug 2019 11:42:52 -0700 Subject: [PATCH] Delete ensureComponentIsNative.js Summary: This function was used by Touchable*. It was removed from the Touchables in D6494579 in 2017. The only remaining callsite was ImageBackground which is attaching a ref directly to the View so we know it is a native component. This is needed for some setNativeProps cleanup Reviewed By: sahrens Differential Revision: D16796973 fbshipit-source-id: 19379094b3b91920efac4bf1969fc22d4b80bcc6 --- .../Touchable/ensureComponentIsNative.js | 23 ------------------- .../UnimplementedViews/UnimplementedView.js | 6 ----- Libraries/Image/ImageBackground.js | 3 --- jest/setup.js | 3 --- 4 files changed, 35 deletions(-) delete mode 100644 Libraries/Components/Touchable/ensureComponentIsNative.js diff --git a/Libraries/Components/Touchable/ensureComponentIsNative.js b/Libraries/Components/Touchable/ensureComponentIsNative.js deleted file mode 100644 index dbf166e4b05..00000000000 --- a/Libraries/Components/Touchable/ensureComponentIsNative.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -'use strict'; - -const invariant = require('invariant'); - -const ensureComponentIsNative = function(component: any) { - invariant( - component && typeof component.setNativeProps === 'function', - 'Touchable child must either be native or forward setNativeProps to a ' + - 'native component', - ); -}; - -module.exports = ensureComponentIsNative; diff --git a/Libraries/Components/UnimplementedViews/UnimplementedView.js b/Libraries/Components/UnimplementedViews/UnimplementedView.js index 4d091bd660f..59725244cef 100644 --- a/Libraries/Components/UnimplementedViews/UnimplementedView.js +++ b/Libraries/Components/UnimplementedViews/UnimplementedView.js @@ -17,12 +17,6 @@ const StyleSheet = require('../../StyleSheet/StyleSheet'); * View component and renders its children. */ class UnimplementedView extends React.Component<$FlowFixMeProps> { - setNativeProps() { - // Do nothing. - // This method is required in order to use this view as a Touchable* child. - // See ensureComponentIsNative.js for more info - } - render(): React.Node { // Workaround require cycle from requireNativeComponent const View = require('../View/View'); diff --git a/Libraries/Image/ImageBackground.js b/Libraries/Image/ImageBackground.js index e6baa48012c..f9f694f6084 100644 --- a/Libraries/Image/ImageBackground.js +++ b/Libraries/Image/ImageBackground.js @@ -14,8 +14,6 @@ const React = require('react'); const StyleSheet = require('../StyleSheet/StyleSheet'); const View = require('../Components/View/View'); -const ensureComponentIsNative = require('../Components/Touchable/ensureComponentIsNative'); - /** * Very simple drop-in replacement for which supports nesting views. * @@ -45,7 +43,6 @@ class ImageBackground extends React.Component<$FlowFixMeProps> { // Work-around flow const viewRef = this._viewRef; if (viewRef) { - ensureComponentIsNative(viewRef); viewRef.setNativeProps(props); } } diff --git a/jest/setup.js b/jest/setup.js index 644d659241c..954d9fd76d2 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -172,9 +172,6 @@ jest return ReactNative; }) - .mock('../Libraries/Components/Touchable/ensureComponentIsNative', () => () => - true, - ) // Mock modules defined by the native layer (ex: Objective-C, Java) .mock('../Libraries/BatchedBridge/NativeModules', () => ({ AlertManager: {