Rendering into an empty React-rendered element should not warn

Only warn if the container has a React-rendered child.
This commit is contained in:
Andrew Clark
2017-02-06 14:22:16 -08:00
parent 87bc7cef2c
commit 255e5aeb3e
+3 -2
View File
@@ -399,10 +399,11 @@ var ReactDOM = {
if (__DEV__) {
const isRootRenderedBySomeReact = Boolean(container._reactRootContainer);
const isInTreeRenderedByThisReact = ReactDOMComponentTree.getInstanceFromNode(container);
const rootEl = getReactRootElementInContainer(container);
const hasNonRootReactChild = Boolean(rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl));
warning(
!isInTreeRenderedByThisReact ||
!hasNonRootReactChild ||
isRootRenderedBySomeReact,
'render(...): Replacing React-rendered children with a new root ' +
'component. If you intended to update the children of this node, ' +