Skip to content

Commit 1747f2b

Browse files
committed
fix: delete ReactNativePropRegistry
Copied from: react/react-native@a8e3c7f
1 parent 90e0c79 commit 1747f2b

4 files changed

Lines changed: 14 additions & 52 deletions

File tree

Libraries/Renderer/shims/ReactNativePropRegistry.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

Libraries/StyleSheet/StyleSheet.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
'use strict';
1313

1414
const PixelRatio = require('PixelRatio');
15-
const ReactNativePropRegistry = require('ReactNativePropRegistry');
1615
const ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
1716
const StyleSheetValidation = require('StyleSheetValidation');
1817

@@ -37,15 +36,16 @@ if (hairlineWidth === 0) {
3736
hairlineWidth = 1 / PixelRatio.get();
3837
}
3938

40-
const absoluteFillObject = {
39+
const absoluteFill = {
4140
position: ('absolute': 'absolute'),
4241
left: 0,
4342
right: 0,
4443
top: 0,
4544
bottom: 0,
4645
};
47-
const absoluteFill: typeof absoluteFillObject =
48-
ReactNativePropRegistry.register(absoluteFillObject); // This also freezes it
46+
if (__DEV__) {
47+
Object.freeze(absoluteFill);
48+
}
4949

5050
/**
5151
* A StyleSheet is an abstraction similar to CSS StyleSheets
@@ -132,7 +132,7 @@ module.exports = {
132132
* },
133133
* });
134134
*/
135-
absoluteFillObject,
135+
absoluteFillObject: absoluteFill,
136136

137137
/**
138138
* Combines two styles such that `style2` will override any styles in `style1`.
@@ -221,11 +221,12 @@ module.exports = {
221221
* Creates a StyleSheet style reference from the given object.
222222
*/
223223
create<S: Styles>(obj: S): StyleSheet<S> {
224-
const result = {};
225-
for (const key in obj) {
226-
StyleSheetValidation.validateStyle(key, obj);
227-
result[key] = obj[key] && ReactNativePropRegistry.register(obj[key]);
224+
if (__DEV__) {
225+
for (const key in obj) {
226+
StyleSheetValidation.validateStyle(key, obj);
227+
Object.freeze(obj[key]);
228+
}
228229
}
229-
return result;
230+
return obj;
230231
},
231232
};

Libraries/StyleSheet/flattenStyle.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,15 @@
1111
*/
1212
'use strict';
1313

14-
var invariant = require('fbjs/lib/invariant');
15-
var ReactNativePropRegistry;
16-
1714
import type { StyleObj } from 'StyleSheetTypes';
1815

19-
function getStyle(style) {
20-
if (ReactNativePropRegistry === undefined) {
21-
ReactNativePropRegistry = require('ReactNativePropRegistry');
22-
}
23-
if (typeof style === 'number') {
24-
return ReactNativePropRegistry.getByID(style);
25-
}
26-
return style;
27-
}
28-
2916
function flattenStyle(style: ?StyleObj): ?Object {
30-
if (!style) {
17+
if (style === null || typeof style !== 'object') {
3118
return undefined;
3219
}
33-
invariant(style !== true, 'style may be false but not true');
3420

3521
if (!Array.isArray(style)) {
36-
/* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an
37-
* error found when Flow v0.63 was deployed. To see the error delete this
38-
* comment and run Flow. */
39-
return getStyle(style);
22+
return style;
4023
}
4124

4225
var result = {};

jest/setup.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,7 @@ Object.keys(mockNativeModules).forEach(module => {
318318
});
319319

320320
jest
321-
.doMock('NativeModules', () => mockNativeModules)
322-
.doMock('ReactNativePropRegistry', () => ({
323-
register: id => id,
324-
getByID: () => mockEmptyObject,
325-
}));
321+
.doMock('NativeModules', () => mockNativeModules);
326322

327323
jest.doMock('requireNativeComponent', () => {
328324
const React = require('react');

0 commit comments

Comments
 (0)