From ae193942feaaacb6511d198c0199bfc3b7bfdbfd Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Thu, 9 Jul 2020 11:38:27 -0700 Subject: [PATCH] RN: Remove `fbjs/{keyMirror,keyOf}` Dependencies Summary: Removes `fbjs/keyMirror` and `fbjs/keyOf` call sites from React Native. Changelog: [Internal] Reviewed By: cpojer Differential Revision: D22438238 fbshipit-source-id: 0f84b6e9d81811f95a2a24886f38ad16b8e6e74f --- Libraries/Components/Touchable/Touchable.js | 39 +++++++++---------- Libraries/Interaction/InteractionManager.js | 9 ++--- Libraries/Utilities/buildStyleInterpolator.js | 8 ++-- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index a55164413f4..8bfa1cb75ee 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -21,7 +21,6 @@ const UIManager = require('../../ReactNative/UIManager'); const View = require('../View/View'); const SoundManager = require('../Sound/SoundManager'); -const keyMirror = require('fbjs/lib/keyMirror'); const normalizeColor = require('../../StyleSheet/normalizeColor'); import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType'; @@ -129,16 +128,16 @@ const extractSingleTouch = nativeEvent => { * Touchable states. */ -const States = keyMirror({ - NOT_RESPONDER: null, // Not the responder - RESPONDER_INACTIVE_PRESS_IN: null, // Responder, inactive, in the `PressRect` - RESPONDER_INACTIVE_PRESS_OUT: null, // Responder, inactive, out of `PressRect` - RESPONDER_ACTIVE_PRESS_IN: null, // Responder, active, in the `PressRect` - RESPONDER_ACTIVE_PRESS_OUT: null, // Responder, active, out of `PressRect` - RESPONDER_ACTIVE_LONG_PRESS_IN: null, // Responder, active, in the `PressRect`, after long press threshold - RESPONDER_ACTIVE_LONG_PRESS_OUT: null, // Responder, active, out of `PressRect`, after long press threshold - ERROR: null, -}); +const States = { + NOT_RESPONDER: 'NOT_RESPONDER', // Not the responder + RESPONDER_INACTIVE_PRESS_IN: 'RESPONDER_INACTIVE_PRESS_IN', // Responder, inactive, in the `PressRect` + RESPONDER_INACTIVE_PRESS_OUT: 'RESPONDER_INACTIVE_PRESS_OUT', // Responder, inactive, out of `PressRect` + RESPONDER_ACTIVE_PRESS_IN: 'RESPONDER_ACTIVE_PRESS_IN', // Responder, active, in the `PressRect` + RESPONDER_ACTIVE_PRESS_OUT: 'RESPONDER_ACTIVE_PRESS_OUT', // Responder, active, out of `PressRect` + RESPONDER_ACTIVE_LONG_PRESS_IN: 'RESPONDER_ACTIVE_LONG_PRESS_IN', // Responder, active, in the `PressRect`, after long press threshold + RESPONDER_ACTIVE_LONG_PRESS_OUT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT', // Responder, active, out of `PressRect`, after long press threshold + ERROR: 'ERROR', +}; type State = | typeof States.NOT_RESPONDER @@ -190,15 +189,15 @@ const IsLongPressingIn = { /** * Inputs to the state machine. */ -const Signals = keyMirror({ - DELAY: null, - RESPONDER_GRANT: null, - RESPONDER_RELEASE: null, - RESPONDER_TERMINATED: null, - ENTER_PRESS_RECT: null, - LEAVE_PRESS_RECT: null, - LONG_PRESS_DETECTED: null, -}); +const Signals = { + DELAY: 'DELAY', + RESPONDER_GRANT: 'RESPONDER_GRANT', + RESPONDER_RELEASE: 'RESPONDER_RELEASE', + RESPONDER_TERMINATED: 'RESPONDER_TERMINATED', + ENTER_PRESS_RECT: 'ENTER_PRESS_RECT', + LEAVE_PRESS_RECT: 'LEAVE_PRESS_RECT', + LONG_PRESS_DETECTED: 'LONG_PRESS_DETECTED', +}; type Signal = | typeof Signals.DELAY diff --git a/Libraries/Interaction/InteractionManager.js b/Libraries/Interaction/InteractionManager.js index 1bf5cbf032d..c438a67e7a9 100644 --- a/Libraries/Interaction/InteractionManager.js +++ b/Libraries/Interaction/InteractionManager.js @@ -15,7 +15,6 @@ const TaskQueue = require('./TaskQueue'); const infoLog = require('../Utilities/infoLog'); const invariant = require('invariant'); -const keyMirror = require('fbjs/lib/keyMirror'); import EventEmitter from '../vendor/emitter/EventEmitter'; @@ -77,10 +76,10 @@ const DEBUG: false = false; * from executing, making apps more responsive. */ const InteractionManager = { - Events: keyMirror({ - interactionStart: true, - interactionComplete: true, - }), + Events: { + interactionStart: 'interactionStart', + interactionComplete: 'interactionComplete', + }, /** * Schedule a function to run after all interactions have completed. Returns a cancellable diff --git a/Libraries/Utilities/buildStyleInterpolator.js b/Libraries/Utilities/buildStyleInterpolator.js index a7ab6d89385..ed86a32df6b 100644 --- a/Libraries/Utilities/buildStyleInterpolator.js +++ b/Libraries/Utilities/buildStyleInterpolator.js @@ -9,11 +9,9 @@ 'use strict'; -const keyOf = require('fbjs/lib/keyOf'); - -const X_DIM = keyOf({x: null}); -const Y_DIM = keyOf({y: null}); -const Z_DIM = keyOf({z: null}); +const X_DIM = 'x'; +const Y_DIM = 'y'; +const Z_DIM = 'z'; const InitialOperationField = { transformTranslate: [0, 0, 0],