Rendering into an empty React-rendered element should not warn
Only warn if the container has a React-rendered child.
Andrew Clark committed
Feb 6, 2017 at 14:22 UTC
255e5aeb3eeb5d3e8de5ab450bb9ac9682f647b4
1 file changed
+3
-2
src/renderers/dom/fiber/ReactDOMFiber.js
+3
-2
@@ -399,10 +399,11 @@ var ReactDOM = {
399
400
if (__DEV__) {
401
const isRootRenderedBySomeReact = Boolean(container._reactRootContainer);
402
- const isInTreeRenderedByThisReact = ReactDOMComponentTree.getInstanceFromNode(container);
402
+ const rootEl = getReactRootElementInContainer(container);
403
+ const hasNonRootReactChild = Boolean(rootEl && ReactDOMComponentTree.getInstanceFromNode(rootEl));
404
405
warning(
405
- !isInTreeRenderedByThisReact ||
406
+ !hasNonRootReactChild ||
407
isRootRenderedBySomeReact,
408
'render(...): Replacing React-rendered children with a new root ' +
409
'component. If you intended to update the children of this node, ' +