diff --git a/packages/react-native-renderer/src/ReactFabric.js b/packages/react-native-renderer/src/ReactFabric.js index ebaeae8214e4..b182111abad5 100644 --- a/packages/react-native-renderer/src/ReactFabric.js +++ b/packages/react-native-renderer/src/ReactFabric.js @@ -21,7 +21,6 @@ import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin'; import ReactNativeComponent from './ReactNativeComponent'; import * as ReactNativeComponentTree from './ReactNativeComponentTree'; import ReactFabricRenderer from './ReactFabricRenderer'; -import ReactNativePropRegistry from './ReactNativePropRegistry'; import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; import createReactNativeComponentClass from './createReactNativeComponentClass'; import {injectFindHostInstance} from './findNodeHandle'; @@ -82,7 +81,6 @@ const ReactFabric: ReactNativeType = { // Used by react-native-github/Libraries/ components ReactNativeBridgeEventPlugin, // requireNativeComponent ReactNativeComponentTree, // ScrollResponder - ReactNativePropRegistry, // flattenStyle, Stylesheet createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART }, }; diff --git a/packages/react-native-renderer/src/ReactNativeAttributePayload.js b/packages/react-native-renderer/src/ReactNativeAttributePayload.js index fda0bd7962fb..d1087d47ff4f 100644 --- a/packages/react-native-renderer/src/ReactNativeAttributePayload.js +++ b/packages/react-native-renderer/src/ReactNativeAttributePayload.js @@ -11,8 +11,6 @@ import deepDiffer from 'deepDiffer'; import flattenStyle from 'flattenStyle'; -import ReactNativePropRegistry from './ReactNativePropRegistry'; - const emptyObject = {}; /** @@ -38,7 +36,7 @@ type AttributeConfiguration = { | AttributeConfiguration /*| boolean*/, }; -type NestedNode = Array | Object | number; +type NestedNode = Array | Object; // Tracks removed keys let removedKeys = null; @@ -54,13 +52,6 @@ function defaultDiffer(prevProp: mixed, nextProp: mixed): boolean { } } -function resolveObject(idOrObject: number | Object): Object { - if (typeof idOrObject === 'number') { - return ReactNativePropRegistry.getByID(idOrObject); - } - return idOrObject; -} - function restoreDeletedValuesInNestedArray( updatePayload: Object, node: NestedNode, @@ -76,7 +67,7 @@ function restoreDeletedValuesInNestedArray( ); } } else if (node && removedKeyCount > 0) { - const obj = resolveObject(node); + const obj = node; for (const propKey in removedKeys) { if (!removedKeys[propKey]) { continue; @@ -180,12 +171,7 @@ function diffNestedProperty( if (!Array.isArray(prevProp) && !Array.isArray(nextProp)) { // Both are leaves, we can diff the leaves. - return diffProperties( - updatePayload, - resolveObject(prevProp), - resolveObject(nextProp), - validAttributes, - ); + return diffProperties(updatePayload, prevProp, nextProp, validAttributes); } if (Array.isArray(prevProp) && Array.isArray(nextProp)) { @@ -204,14 +190,14 @@ function diffNestedProperty( // $FlowFixMe - We know that this is always an object when the input is. flattenStyle(prevProp), // $FlowFixMe - We know that this isn't an array because of above flow. - resolveObject(nextProp), + nextProp, validAttributes, ); } return diffProperties( updatePayload, - resolveObject(prevProp), + prevProp, // $FlowFixMe - We know that this is always an object when the input is. flattenStyle(nextProp), validAttributes, @@ -234,11 +220,7 @@ function addNestedProperty( if (!Array.isArray(nextProp)) { // Add each property of the leaf. - return addProperties( - updatePayload, - resolveObject(nextProp), - validAttributes, - ); + return addProperties(updatePayload, nextProp, validAttributes); } for (let i = 0; i < nextProp.length; i++) { @@ -268,11 +250,7 @@ function clearNestedProperty( if (!Array.isArray(prevProp)) { // Add each property of the leaf. - return clearProperties( - updatePayload, - resolveObject(prevProp), - validAttributes, - ); + return clearProperties(updatePayload, prevProp, validAttributes); } for (let i = 0; i < prevProp.length; i++) { diff --git a/packages/react-native-renderer/src/ReactNativePropRegistry.js b/packages/react-native-renderer/src/ReactNativePropRegistry.js deleted file mode 100644 index 0eb34ba7c46a..000000000000 --- a/packages/react-native-renderer/src/ReactNativePropRegistry.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * 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. - * - * @flow - */ - -const objects = {}; -let uniqueID = 1; -const emptyObject = {}; - -class ReactNativePropRegistry { - static register(object: Object): number { - const id = ++uniqueID; - if (__DEV__) { - Object.freeze(object); - } - objects[id] = object; - return id; - } - - static getByID(id: number): Object { - if (!id) { - // Used in the style={[condition && id]} pattern, - // we want it to be a no-op when the value is false or null - return emptyObject; - } - - const object = objects[id]; - if (!object) { - console.warn('Invalid style with id `' + id + '`. Skipping ...'); - return emptyObject; - } - return object; - } -} - -export default ReactNativePropRegistry; diff --git a/packages/react-native-renderer/src/ReactNativeRenderer.js b/packages/react-native-renderer/src/ReactNativeRenderer.js index c4bec308e214..8c1c8c348b44 100644 --- a/packages/react-native-renderer/src/ReactNativeRenderer.js +++ b/packages/react-native-renderer/src/ReactNativeRenderer.js @@ -25,7 +25,6 @@ import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin'; import ReactNativeComponent from './ReactNativeComponent'; import * as ReactNativeComponentTree from './ReactNativeComponentTree'; import ReactNativeFiberRenderer from './ReactNativeFiberRenderer'; -import ReactNativePropRegistry from './ReactNativePropRegistry'; import {getInspectorDataForViewTag} from './ReactNativeFiberInspector'; import createReactNativeComponentClass from './createReactNativeComponentClass'; import {injectFindHostInstance} from './findNodeHandle'; @@ -101,7 +100,6 @@ const ReactNativeRenderer: ReactNativeType = { // Used by react-native-github/Libraries/ components ReactNativeBridgeEventPlugin, // requireNativeComponent ReactNativeComponentTree, // ScrollResponder - ReactNativePropRegistry, // flattenStyle, Stylesheet createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART computeComponentStackForErrorReporting, }, diff --git a/packages/react-native-renderer/src/ReactNativeTypes.js b/packages/react-native-renderer/src/ReactNativeTypes.js index f20bb30faa79..e84d222b51da 100644 --- a/packages/react-native-renderer/src/ReactNativeTypes.js +++ b/packages/react-native-renderer/src/ReactNativeTypes.js @@ -81,7 +81,6 @@ type SecretInternalsType = { ): any, ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin, ReactNativeComponentTree: any, - ReactNativePropRegistry: any, // TODO (bvaughn) Decide which additional types to expose here? // And how much information to fill in for the above types. }; diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js b/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js index 30423b2f0d8e..cfb3354ca176 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeAttributePayload-test.js @@ -9,7 +9,6 @@ 'use strict'; const ReactNativeAttributePayload = require('../ReactNativeAttributePayload'); -const ReactNativePropRegistry = require('../ReactNativePropRegistry').default; const diff = ReactNativeAttributePayload.diff; @@ -114,9 +113,9 @@ describe('ReactNativeAttributePayload', () => { diff({someStyle: [{foo: 1}, {bar: 2}]}, {}, validStyleAttribute), ).toEqual({foo: null, bar: null}); - const barStyle = ReactNativePropRegistry.register({ + const barStyle = { bar: 3, - }); + }; expect( diff( diff --git a/scripts/rollup/shims/react-native/ReactNativePropRegistry.js b/scripts/rollup/shims/react-native/ReactNativePropRegistry.js deleted file mode 100644 index 1ffd01057d51..000000000000 --- a/scripts/rollup/shims/react-native/ReactNativePropRegistry.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2013-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. - * - * @providesModule ReactNativePropRegistry - * @flow - */ - -'use strict'; - -const { - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, -} = require('ReactNative'); - -module.exports = - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactNativePropRegistry;