Skip to content

Commit

Permalink
Move createReactNativeComponentClass to shims and delete internal usage
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage committed Apr 10, 2018
1 parent b0019b4 commit 492d3ad
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 72 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 @@ -21,7 +21,6 @@ import ReactNativeComponent from './ReactNativeComponent';
import * as ReactNativeComponentTree from './ReactNativeComponentTree';
import ReactFabricRenderer from './ReactFabricRenderer';
import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
import createReactNativeComponentClass from './createReactNativeComponentClass';
import {injectFindHostInstance} from './findNodeHandle';
import findNumericNodeHandle from './findNumericNodeHandle';

Expand Down Expand Up @@ -73,7 +72,6 @@ const ReactFabric: ReactFabricType = {
NativeMethodsMixin,
// Used by react-native-github/Libraries/ components
ReactNativeComponentTree, // ScrollResponder
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
},
};

Expand Down
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 @@ -25,7 +25,6 @@ import ReactNativeComponent from './ReactNativeComponent';
import * as ReactNativeComponentTree from './ReactNativeComponentTree';
import ReactNativeFiberRenderer from './ReactNativeFiberRenderer';
import {getInspectorDataForViewTag} from './ReactNativeFiberInspector';
import createReactNativeComponentClass from './createReactNativeComponentClass';
import {injectFindHostInstance} from './findNodeHandle';
import findNumericNodeHandle from './findNumericNodeHandle';

Expand Down Expand Up @@ -98,7 +97,6 @@ const ReactNativeRenderer: ReactNativeType = {
NativeMethodsMixin,
// Used by react-native-github/Libraries/ components
ReactNativeComponentTree, // ScrollResponder
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
computeComponentStackForErrorReporting,
},
};
Expand Down
4 changes: 0 additions & 4 deletions packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ export type NativeMethodsMixinType = {

type SecretInternalsType = {
NativeMethodsMixin: NativeMethodsMixinType,
createReactNativeComponentClass(
name: string,
callback: ViewConfigGetter,
): any,
ReactNativeComponentTree: any,
// TODO (bvaughn) Decide which additional types to expose here?
// And how much information to fill in for the above types.
Expand Down
18 changes: 0 additions & 18 deletions packages/react-native-renderer/src/__mocks__/View.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ describe('ReactFabric', () => {
ReactFabric = require('react-native-renderer/fabric');
FabricUIManager = require('FabricUIManager');
UIManager = require('UIManager');
createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
.register;
});

it('should be able to create and render a native component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ describe('ReactNativeError', () => {

React = require('react');
ReactNative = require('react-native-renderer');
createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
.register;
computeComponentStackForErrorReporting =
ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.computeComponentStackForErrorReporting;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ beforeEach(() => {
ReactNative = require('react-native-renderer');
ResponderEventPlugin = require('events/ResponderEventPlugin').default;
UIManager = require('UIManager');
createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
.register;
});

it('fails if unknown/unsupported event types are dispatched', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ describe('ReactNative', () => {
React = require('react');
ReactNative = require('react-native-renderer');
UIManager = require('UIManager');
createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
.register;
});

it('should be able to create and render a native component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('createReactNativeComponentClass', () => {
beforeEach(() => {
jest.resetModules();

createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
.register;
React = require('react');
ReactNative = require('react-native-renderer');
});
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const bundles = [
'RCTEventEmitter',
'TextInputState',
'UIManager',
'View',
'deepDiffer',
'deepFreezeAndThrowOnMutationInDev',
'flattenStyle',
Expand All @@ -147,7 +146,6 @@ const bundles = [
'TextInputState',
'UIManager',
'FabricUIManager',
'View',
'deepDiffer',
'deepFreezeAndThrowOnMutationInDev',
'flattenStyle',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,23 @@

'use strict';

const {
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
} = require('ReactNative');
import type {ViewConfigGetter} from './ReactNativeTypes';

module.exports =
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.createReactNativeComponentClass;
const {register} = require('ReactNativeViewConfigRegistry');

/**
* Creates a renderable ReactNative host component.
* Use this method for view configs that are loaded from UIManager.
* Use createReactNativeComponentClass() for view configs defined within JavaScript.
*
* @param {string} config iOS View configuration.
* @private
*/
const createReactNativeComponentClass = function(
name: string,
callback: ViewConfigGetter,
): string {
return register(name, callback);
};

export default createReactNativeComponentClass;

0 comments on commit 492d3ad

Please sign in to comment.