diff --git a/src/renderers/dom/client/ReactMount.js b/src/renderers/dom/client/ReactMount.js index d0a0fdd8886fb..307f9123b1f4d 100644 --- a/src/renderers/dom/client/ReactMount.js +++ b/src/renderers/dom/client/ReactMount.js @@ -274,7 +274,11 @@ function mountComponentIntoNode( var markup = ReactReconciler.mountComponent( componentInstance, rootID, transaction, context ); - componentInstance._isTopLevel = true; + if (typeof componentInstance._renderedComponent._currentElement.type === + 'function') { + // hax + componentInstance._renderedComponent._isTopLevel = true; + } ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup); } @@ -328,6 +332,17 @@ function unmountComponentFromNode(instance, container) { } } +/** + * Temporary (?) hack so that we can store all top-level pending updates on + * composites instead of having to worry about different types of components + * here. + */ +var TopLevelWrapper = function() {}; +TopLevelWrapper.prototype.render = function() { + // this.props is actually a ReactElement + return this.props; +}; + /** * Mounting is the process of initializing a React component by creating its * representative DOM elements and inserting them into a supplied `container`. @@ -522,17 +537,26 @@ var ReactMount = { 'for your app.' ); + var nextWrappedElement = new ReactElement( + TopLevelWrapper, + null, + null, + null, + nextElement + ); + var prevComponent = instancesByReactRootID[getReactRootID(container)]; if (prevComponent) { - var prevElement = prevComponent._currentElement; + var prevWrappedElement = prevComponent._currentElement; + var prevElement = prevWrappedElement.props; if (shouldUpdateReactComponent(prevElement, nextElement)) { return ReactMount._updateRootComponent( prevComponent, - nextElement, + nextWrappedElement, container, callback - ).getPublicInstance(); + )._renderedComponent.getPublicInstance(); } else { ReactMount.unmountComponentAtNode(container); } @@ -563,7 +587,7 @@ var ReactMount = { var shouldReuseMarkup = containerHasReactMarkup && !prevComponent; var component = ReactMount._renderNewRootComponent( - nextElement, + nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? @@ -571,7 +595,7 @@ var ReactMount = { parentComponent._reactInternalInstance._context ) : emptyObject - ).getPublicInstance(); + )._renderedComponent.getPublicInstance(); if (callback) { callback.call(component); }