Skip to content

Commit ebde434

Browse files
committed
Move createReactNativeComponentClass to shims and delete internal usage
Since createReactNativeComponentClass is just an alias for the register there's no need to bundle it. This file should probably just move back to RN too.
1 parent b0019b4 commit ebde434

13 files changed

+31
-74
lines changed

packages/react-native-renderer/src/ReactFabric.js

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import ReactNativeComponent from './ReactNativeComponent';
2121
import * as ReactNativeComponentTree from './ReactNativeComponentTree';
2222
import ReactFabricRenderer from './ReactFabricRenderer';
2323
import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
24-
import createReactNativeComponentClass from './createReactNativeComponentClass';
2524
import {injectFindHostInstance} from './findNodeHandle';
2625
import findNumericNodeHandle from './findNumericNodeHandle';
2726

@@ -73,7 +72,6 @@ const ReactFabric: ReactFabricType = {
7372
NativeMethodsMixin,
7473
// Used by react-native-github/Libraries/ components
7574
ReactNativeComponentTree, // ScrollResponder
76-
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
7775
},
7876
};
7977

packages/react-native-renderer/src/ReactNativeRenderer.js

-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import ReactNativeComponent from './ReactNativeComponent';
2525
import * as ReactNativeComponentTree from './ReactNativeComponentTree';
2626
import ReactNativeFiberRenderer from './ReactNativeFiberRenderer';
2727
import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
28-
import createReactNativeComponentClass from './createReactNativeComponentClass';
2928
import {injectFindHostInstance} from './findNodeHandle';
3029
import findNumericNodeHandle from './findNumericNodeHandle';
3130

@@ -98,7 +97,6 @@ const ReactNativeRenderer: ReactNativeType = {
9897
NativeMethodsMixin,
9998
// Used by react-native-github/Libraries/ components
10099
ReactNativeComponentTree, // ScrollResponder
101-
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
102100
computeComponentStackForErrorReporting,
103101
},
104102
};

packages/react-native-renderer/src/ReactNativeTypes.js

-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ export type NativeMethodsMixinType = {
7171

7272
type SecretInternalsType = {
7373
NativeMethodsMixin: NativeMethodsMixinType,
74-
createReactNativeComponentClass(
75-
name: string,
76-
callback: ViewConfigGetter,
77-
): any,
7874
ReactNativeComponentTree: any,
7975
// TODO (bvaughn) Decide which additional types to expose here?
8076
// And how much information to fill in for the above types.

packages/react-native-renderer/src/__mocks__/View.js

-18
This file was deleted.

packages/react-native-renderer/src/__tests__/ReactFabric-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ describe('ReactFabric', () => {
2828
ReactFabric = require('react-native-renderer/fabric');
2929
FabricUIManager = require('FabricUIManager');
3030
UIManager = require('UIManager');
31-
createReactNativeComponentClass = require('../createReactNativeComponentClass')
32-
.default;
31+
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
32+
.register;
3333
});
3434

3535
it('should be able to create and render a native component', () => {

packages/react-native-renderer/src/__tests__/ReactFabricAndNative-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ describe('ReactFabric', () => {
2626

2727
React = require('react');
2828
ReactFabric = require('react-native-renderer/fabric');
29-
createReactNativeComponentClass = require('../createReactNativeComponentClass')
30-
.default;
29+
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
30+
.register;
3131
});
3232

3333
it('find Fabric nodes with the RN renderer', () => {

packages/react-native-renderer/src/__tests__/ReactNativeError-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ describe('ReactNativeError', () => {
2525

2626
React = require('react');
2727
ReactNative = require('react-native-renderer');
28-
createReactNativeComponentClass = require('../createReactNativeComponentClass')
29-
.default;
28+
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
29+
.register;
3030
computeComponentStackForErrorReporting =
3131
ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
3232
.computeComponentStackForErrorReporting;

packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ beforeEach(() => {
6969
ReactNative = require('react-native-renderer');
7070
ResponderEventPlugin = require('events/ResponderEventPlugin').default;
7171
UIManager = require('UIManager');
72-
createReactNativeComponentClass = require('../createReactNativeComponentClass')
73-
.default;
72+
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
73+
.register;
7474
});
7575

7676
it('fails if unknown/unsupported event types are dispatched', () => {

packages/react-native-renderer/src/__tests__/ReactNativeMount-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ describe('ReactNative', () => {
2222
React = require('react');
2323
ReactNative = require('react-native-renderer');
2424
UIManager = require('UIManager');
25-
createReactNativeComponentClass = require('../createReactNativeComponentClass')
26-
.default;
25+
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
26+
.register;
2727
});
2828

2929
it('should be able to create and render a native component', () => {

packages/react-native-renderer/src/__tests__/createReactNativeComponentClass-test.internal.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describe('createReactNativeComponentClass', () => {
1818
beforeEach(() => {
1919
jest.resetModules();
2020

21-
createReactNativeComponentClass = require('../createReactNativeComponentClass')
22-
.default;
21+
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
22+
.register;
2323
React = require('react');
2424
ReactNative = require('react-native-renderer');
2525
});

packages/react-native-renderer/src/createReactNativeComponentClass.js

-29
This file was deleted.

scripts/rollup/bundles.js

-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ const bundles = [
124124
'RCTEventEmitter',
125125
'TextInputState',
126126
'UIManager',
127-
'View',
128127
'deepDiffer',
129128
'deepFreezeAndThrowOnMutationInDev',
130129
'flattenStyle',
@@ -147,7 +146,6 @@ const bundles = [
147146
'TextInputState',
148147
'UIManager',
149148
'FabricUIManager',
150-
'View',
151149
'deepDiffer',
152150
'deepFreezeAndThrowOnMutationInDev',
153151
'flattenStyle',

scripts/rollup/shims/react-native/createReactNativeComponentClass.js

+19-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,23 @@
1010

1111
'use strict';
1212

13-
const {
14-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
15-
} = require('ReactNative');
13+
import type {ViewConfigGetter} from './ReactNativeTypes';
1614

17-
module.exports =
18-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.createReactNativeComponentClass;
15+
const {register} = require('ReactNativeViewConfigRegistry');
16+
17+
/**
18+
* Creates a renderable ReactNative host component.
19+
* Use this method for view configs that are loaded from UIManager.
20+
* Use createReactNativeComponentClass() for view configs defined within JavaScript.
21+
*
22+
* @param {string} config iOS View configuration.
23+
* @private
24+
*/
25+
const createReactNativeComponentClass = function(
26+
name: string,
27+
callback: ViewConfigGetter,
28+
): string {
29+
return register(name, callback);
30+
};
31+
32+
export default createReactNativeComponentClass;

0 commit comments

Comments
 (0)