Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
sebmarkbage committed Apr 10, 2018
1 parent b0019b4 commit ebde434
Showing 13 changed files with 31 additions and 74 deletions.
2 changes: 0 additions & 2 deletions packages/react-native-renderer/src/ReactFabric.js
Original file line number Diff line number Diff line change
@@ -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';

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

2 changes: 0 additions & 2 deletions packages/react-native-renderer/src/ReactNativeRenderer.js
Original file line number Diff line number Diff line change
@@ -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';

@@ -98,7 +97,6 @@ const ReactNativeRenderer: ReactNativeType = {
NativeMethodsMixin,
// Used by react-native-github/Libraries/ components
ReactNativeComponentTree, // ScrollResponder
createReactNativeComponentClass, // RCTText, RCTView, ReactNativeART
computeComponentStackForErrorReporting,
},
};
4 changes: 0 additions & 4 deletions packages/react-native-renderer/src/ReactNativeTypes.js
Original file line number Diff line number Diff line change
@@ -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.
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
@@ -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', () => {
Original file line number Diff line number Diff line change
@@ -26,8 +26,8 @@ describe('ReactFabric', () => {

React = require('react');
ReactFabric = require('react-native-renderer/fabric');
createReactNativeComponentClass = require('../createReactNativeComponentClass')
.default;
createReactNativeComponentClass = require('ReactNativeViewConfigRegistry')
.register;
});

it('find Fabric nodes with the RN renderer', () => {
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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', () => {
Original file line number Diff line number Diff line change
@@ -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', () => {
Original file line number Diff line number Diff line change
@@ -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');
});

This file was deleted.

2 changes: 0 additions & 2 deletions scripts/rollup/bundles.js
Original file line number Diff line number Diff line change
@@ -124,7 +124,6 @@ const bundles = [
'RCTEventEmitter',
'TextInputState',
'UIManager',
'View',
'deepDiffer',
'deepFreezeAndThrowOnMutationInDev',
'flattenStyle',
@@ -147,7 +146,6 @@ const bundles = [
'TextInputState',
'UIManager',
'FabricUIManager',
'View',
'deepDiffer',
'deepFreezeAndThrowOnMutationInDev',
'flattenStyle',
Original file line number Diff line number Diff line change
@@ -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 ebde434

Please sign in to comment.