Skip to content

Commit

Permalink
Remove ReactNativePropRegistry
Browse files Browse the repository at this point in the history
This has always been an unnecessary indirection to protect opaqueness,
which hasn't really worked out.
  • Loading branch information
sebmarkbage committed Apr 6, 2018
1 parent 7a3416f commit a53e51f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 95 deletions.
2 changes: 0 additions & 2 deletions packages/react-native-renderer/src/ReactFabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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 {injectFindHostInstanceFabric} from './findNodeHandle';
Expand Down Expand Up @@ -86,7 +85,6 @@ const ReactFabric: ReactNativeType = {
// Used by react-native-github/Libraries/ components
ReactNativeBridgeEventPlugin, // requireNativeComponent
ReactNativeComponentTree, // ScrollResponder
ReactNativePropRegistry, // flattenStyle, Stylesheet
TouchHistoryMath, // PanResponder
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
takeSnapshot, // react-native-implementation
Expand Down
36 changes: 7 additions & 29 deletions packages/react-native-renderer/src/ReactNativeAttributePayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import deepDiffer from 'deepDiffer';
import flattenStyle from 'flattenStyle';

import ReactNativePropRegistry from './ReactNativePropRegistry';

const emptyObject = {};

/**
Expand All @@ -38,7 +36,7 @@ type AttributeConfiguration = {
| AttributeConfiguration /*| boolean*/,
};

type NestedNode = Array<NestedNode> | Object | number;
type NestedNode = Array<NestedNode> | Object;

// Tracks removed keys
let removedKeys = null;
Expand All @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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)) {
Expand All @@ -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,
Expand All @@ -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++) {
Expand Down Expand Up @@ -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++) {
Expand Down
40 changes: 0 additions & 40 deletions packages/react-native-renderer/src/ReactNativePropRegistry.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/react-native-renderer/src/ReactNativeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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';
Expand Down Expand Up @@ -105,7 +104,6 @@ const ReactNativeRenderer: ReactNativeType = {
// Used by react-native-github/Libraries/ components
ReactNativeBridgeEventPlugin, // requireNativeComponent
ReactNativeComponentTree, // ScrollResponder
ReactNativePropRegistry, // flattenStyle, Stylesheet
TouchHistoryMath, // PanResponder
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
takeSnapshot, // react-native-implementation
Expand Down
1 change: 0 additions & 1 deletion packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
'use strict';

const ReactNativeAttributePayload = require('../ReactNativeAttributePayload');
const ReactNativePropRegistry = require('../ReactNativePropRegistry').default;

const diff = ReactNativeAttributePayload.diff;

Expand Down Expand Up @@ -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(
Expand Down
18 changes: 0 additions & 18 deletions scripts/rollup/shims/react-native/ReactNativePropRegistry.js

This file was deleted.

0 comments on commit a53e51f

Please sign in to comment.