From 64aa1e5ffe5d577c04cabb3692246b956f65597b Mon Sep 17 00:00:00 2001 From: Luis Miguel Alvarado Date: Mon, 20 Sep 2021 02:00:08 -0700 Subject: [PATCH] chore: removed unused files (#31465) Summary: All these files are unused ## Changelog [JavaScript] [Removed] - chore: removed unused files Pull Request resolved: https://github.com/facebook/react-native/pull/31465 Test Plan: CI is passing Reviewed By: yungsters Differential Revision: D30653225 Pulled By: charlesbdudley fbshipit-source-id: 30c646f10be382c4898a8e362176acc382eb9090 --- Libraries/Components/StaticContainer.react.js | 51 ---------------- .../Touchable/ensurePositiveDelayProps.js | 25 -------- Libraries/Interaction/InteractionMixin.js | 54 ----------------- .../__tests__/InteractionMixin-test.js | 50 ---------------- Libraries/ReactNative/queryLayoutByID.js | 58 ------------------- 5 files changed, 238 deletions(-) delete mode 100644 Libraries/Components/StaticContainer.react.js delete mode 100644 Libraries/Components/Touchable/ensurePositiveDelayProps.js delete mode 100644 Libraries/Interaction/InteractionMixin.js delete mode 100644 Libraries/Interaction/__tests__/InteractionMixin-test.js delete mode 100644 Libraries/ReactNative/queryLayoutByID.js diff --git a/Libraries/Components/StaticContainer.react.js b/Libraries/Components/StaticContainer.react.js deleted file mode 100644 index a84731b08c8311..00000000000000 --- a/Libraries/Components/StaticContainer.react.js +++ /dev/null @@ -1,51 +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 strict-local - */ - -'use strict'; - -const React = require('react'); - -/** - * Renders static content efficiently by allowing React to short-circuit the - * reconciliation process. This component should be used when you know that a - * subtree of components will never need to be updated. - * - * const someValue = ...; // We know for certain this value will never change. - * return ( - * - * - * - * ); - * - * Typically, you will not need to use this component and should opt for normal - * React reconciliation. - */ - -type Props = $ReadOnly<{| - /** - * Whether or not this component should update. - */ - shouldUpdate?: ?boolean, - /** - * Content short-circuited by React reconciliation process. - */ - children: React.Node, -|}>; -class StaticContainer extends React.Component { - shouldComponentUpdate(nextProps: Props): boolean { - return !!nextProps.shouldUpdate; - } - - render(): React.Node { - return this.props.children; - } -} - -module.exports = StaticContainer; diff --git a/Libraries/Components/Touchable/ensurePositiveDelayProps.js b/Libraries/Components/Touchable/ensurePositiveDelayProps.js deleted file mode 100644 index bd9b3028399cd0..00000000000000 --- a/Libraries/Components/Touchable/ensurePositiveDelayProps.js +++ /dev/null @@ -1,25 +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'; -import invariant from 'invariant'; - -const ensurePositiveDelayProps = function(props: any) { - invariant( - !( - props.delayPressIn < 0 || - props.delayPressOut < 0 || - props.delayLongPress < 0 - ), - 'Touchable components cannot have negative delay properties', - ); -}; - -module.exports = ensurePositiveDelayProps; diff --git a/Libraries/Interaction/InteractionMixin.js b/Libraries/Interaction/InteractionMixin.js deleted file mode 100644 index e7c80a90846ec2..00000000000000 --- a/Libraries/Interaction/InteractionMixin.js +++ /dev/null @@ -1,54 +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 - */ - -const InteractionManager = require('./InteractionManager'); -import {type Handle} from './InteractionManager'; - -/** - * This mixin provides safe versions of InteractionManager start/end methods - * that ensures `clearInteractionHandle` is always called - * once per start, even if the component is unmounted. - */ -const InteractionMixin = { - componentWillUnmount: function() { - while (this._interactionMixinHandles.length) { - InteractionManager.clearInteractionHandle( - this._interactionMixinHandles.pop(), - ); - } - }, - - _interactionMixinHandles: ([]: Array), - - createInteractionHandle: function(): Handle { - const handle = InteractionManager.createInteractionHandle(); - this._interactionMixinHandles.push(handle); - return handle; - }, - - // $FlowFixMe[signature-verification-failure] - clearInteractionHandle: function(clearHandle: number): void { - InteractionManager.clearInteractionHandle(clearHandle); - this._interactionMixinHandles = this._interactionMixinHandles.filter( - handle => handle !== clearHandle, - ); - }, - - /** - * Schedule work for after all interactions have completed. - * - * @param {function} callback - */ - runAfterInteractions: function(callback: Function): void { - InteractionManager.runAfterInteractions(callback); - }, -}; - -module.exports = InteractionMixin; diff --git a/Libraries/Interaction/__tests__/InteractionMixin-test.js b/Libraries/Interaction/__tests__/InteractionMixin-test.js deleted file mode 100644 index d7116a8fb25312..00000000000000 --- a/Libraries/Interaction/__tests__/InteractionMixin-test.js +++ /dev/null @@ -1,50 +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 - * @emails oncall+react_native - */ - -'use strict'; - -jest.mock('../InteractionManager'); - -describe('InteractionMixin', () => { - let InteractionManager; - let InteractionMixin; - let component; - - beforeEach(() => { - jest.resetModules(); - InteractionManager = require('../InteractionManager'); - InteractionMixin = require('../InteractionMixin'); - - component = Object.create(InteractionMixin); - }); - - it('should start interactions', () => { - component.createInteractionHandle(); - expect(InteractionManager.createInteractionHandle).toBeCalled(); - }); - - it('should end interactions', () => { - const handle = {}; - component.clearInteractionHandle(handle); - expect(InteractionManager.clearInteractionHandle).toBeCalledWith(handle); - }); - - it('should schedule tasks', () => { - const task = jest.fn(); - component.runAfterInteractions(task); - expect(InteractionManager.runAfterInteractions).toBeCalledWith(task); - }); - - it('should end unfinished interactions in componentWillUnmount', () => { - const handle = component.createInteractionHandle(); - component.componentWillUnmount(); - expect(InteractionManager.clearInteractionHandle).toBeCalledWith(handle); - }); -}); diff --git a/Libraries/ReactNative/queryLayoutByID.js b/Libraries/ReactNative/queryLayoutByID.js deleted file mode 100644 index 5d148af957d04a..00000000000000 --- a/Libraries/ReactNative/queryLayoutByID.js +++ /dev/null @@ -1,58 +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. - * - * @flow - * @format - */ - -'use strict'; - -const UIManager = require('./UIManager'); - -type OnSuccessCallback = ( - left: number, - top: number, - width: number, - height: number, - pageX: number, - pageY: number, -) => void; - -// I don't know what type error is... -type OnErrorCallback = (error: any) => void; - -/** - * Queries the layout of a view. The layout does not reflect the element as - * seen by the user, rather it reflects the position within the layout system, - * before any transforms are applied. - * - * The only other requirement is that the `pageX, pageY` values be in the same - * coordinate system that events' `pageX/Y` are reported. That means that for - * the web, `pageXOffset/pageYOffset` should be added to to - * getBoundingClientRect to make consistent with touches. - * - * var pageXOffset = window.pageXOffset; - * var pageYOffset = window.pageYOffset; - * - * This is an IOS specific implementation. - * - * @param {number} tag ID of the platform specific node to be measured. - * @param {function} onError `func(error)` - * @param {function} onSuccess `func(left, top, width, height, pageX, pageY)` - */ -const queryLayoutByID = function( - tag: ?number, - onError: OnErrorCallback, - onSuccess: OnSuccessCallback, -): void { - if (tag == null) { - return; - } - // Native bridge doesn't *yet* surface errors. - UIManager.measure(tag, onSuccess); -}; - -module.exports = queryLayoutByID;