Skip to content

Commit

Permalink
Cut out isomorphic dependencies from the renderers
Browse files Browse the repository at this point in the history
These files reaches into isomorphic files.

The ReactElement functions are exposed on the React object anyway
so I can just use those instead.

I also found some files that are not shared that should be in
renderers shared.
  • Loading branch information
sebmarkbage committed Jul 2, 2016
1 parent 7032362 commit b04acc6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
1 change: 1 addition & 0 deletions grunt/config/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var SECRET_DOM_INTERNALS_NAME = 'ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_W
var shimSharedModules = globalShim.configure({
'./ReactCurrentOwner': SECRET_INTERNALS_NAME + '.ReactCurrentOwner',
'./ReactComponentTreeDevtool': SECRET_INTERNALS_NAME + '.ReactComponentTreeDevtool',
'./ReactElement': 'React', // All the methods that are shared are exposed.
});

// Shim references to ReactDOM internals from addons.
Expand Down
16 changes: 5 additions & 11 deletions src/renderers/dom/client/ReactMount.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function mountComponentIntoNode(
) {
var markerName;
if (ReactFeatureFlags.logTopLevelRenders) {
var wrappedElement = wrapperInstance._currentElement.props;
var wrappedElement = wrapperInstance._currentElement.props.child;
var type = wrappedElement.type;
markerName = 'React mount: ' + (
typeof type === 'string' ? type :
Expand Down Expand Up @@ -235,8 +235,7 @@ if (__DEV__) {
TopLevelWrapper.displayName = 'TopLevelWrapper';
}
TopLevelWrapper.prototype.render = function() {
// this.props is actually a ReactElement
return this.props;
return this.props.child;
};

/**
Expand Down Expand Up @@ -432,14 +431,9 @@ var ReactMount = {
'for your app.'
);

var nextWrappedElement = ReactElement(
var nextWrappedElement = ReactElement.createElement(
TopLevelWrapper,
null,
null,
null,
null,
null,
nextElement
{ child: nextElement }
);

var nextContext;
Expand All @@ -454,7 +448,7 @@ var ReactMount = {

if (prevComponent) {
var prevWrappedElement = prevComponent._currentElement;
var prevElement = prevWrappedElement.props;
var prevElement = prevWrappedElement.props.child;
if (shouldUpdateReactComponent(prevElement, nextElement)) {
var publicInst = prevComponent._renderedComponent.getPublicInstance();
var updatedCallback = callback && function() {
Expand Down
24 changes: 14 additions & 10 deletions src/renderers/shared/stack/reconciler/ReactCompositeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ var ReactErrorUtils = require('ReactErrorUtils');
var ReactInstanceMap = require('ReactInstanceMap');
var ReactInstrumentation = require('ReactInstrumentation');
var ReactNodeTypes = require('ReactNodeTypes');
var ReactPropTypeLocations = require('ReactPropTypeLocations');
var ReactReconciler = require('ReactReconciler');
var ReactUpdateQueue = require('ReactUpdateQueue');

var checkReactTypeSpec = require('checkReactTypeSpec');
if (__DEV__) {
var ReactPropTypeLocations = require('ReactPropTypeLocations');
var checkReactTypeSpec = require('checkReactTypeSpec');
}

var emptyObject = require('emptyObject');
var invariant = require('invariant');
Expand Down Expand Up @@ -677,14 +679,16 @@ var ReactCompositeComponentMixin = {
* @private
*/
_checkContextTypes: function(typeSpecs, values, location) {
checkReactTypeSpec(
typeSpecs,
values,
location,
this.getName(),
null,
this._debugID
);
if (__DEV__) {
checkReactTypeSpec(
typeSpecs,
values,
location,
this.getName(),
null,
this._debugID
);
}
},

receiveComponent: function(nextElement, transaction, nextContext) {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/renderers/shared/stack/reconciler/ReactUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function runBatchedUpdates(transaction) {
var namedComponent = component;
// Duck type TopLevelWrapper. This is probably always true.
if (
component._currentElement.props ===
component._currentElement.props.child ===
component._renderedComponent._currentElement
) {
namedComponent = component._renderedComponent;
Expand Down

0 comments on commit b04acc6

Please sign in to comment.