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 8, 2018
1 parent 4100d8c commit 6bc4350
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 @@ -22,7 +22,6 @@ 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';
import findNumericNodeHandle from './findNumericNodeHandle';
import takeSnapshot from './takeSnapshot';
Expand Down Expand Up @@ -82,7 +81,6 @@ const ReactFabric: ReactNativeType = {
// Used by react-native-github/Libraries/ components
ReactNativeComponentTree, // ScrollResponder
ReactNativePropRegistry, // flattenStyle, Stylesheet
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
takeSnapshot, // react-native-implementation
},
};
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 @@ -26,7 +26,6 @@ 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';
import findNumericNodeHandle from './findNumericNodeHandle';
import takeSnapshot from './takeSnapshot';
Expand Down Expand Up @@ -101,7 +100,6 @@ const ReactNativeRenderer: ReactNativeType = {
// Used by react-native-github/Libraries/ components
ReactNativeComponentTree, // ScrollResponder
ReactNativePropRegistry, // flattenStyle, Stylesheet
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
takeSnapshot, // react-native-implementation
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,
ReactNativePropRegistry: any,
// TODO (bvaughn) Decide which additional types to expose here?
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 6bc4350

Please sign in to comment.