File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -499,8 +499,25 @@ function renderSubtreeIntoContainer(
499499 // First clear any existing content.
500500 // TODO: Figure out the best heuristic here.
501501 if ( ! shouldReuseContent ( container ) ) {
502- while ( container . lastChild ) {
503- container . removeChild ( container . lastChild ) ;
502+ let warned = false ;
503+ let rootSibling ;
504+ while ( ( rootSibling = container . lastChild ) ) {
505+ if ( __DEV__ ) {
506+ if (
507+ ! warned &&
508+ rootSibling . nodeType === ELEMENT_NODE &&
509+ ( rootSibling : any ) . hasAttribute ( ID_ATTRIBUTE_NAME )
510+ ) {
511+ warned = true ;
512+ warning (
513+ false ,
514+ 'render(): Target node has markup rendered by React, but there ' +
515+ 'are unrelated nodes as well. This is most commonly caused by ' +
516+ 'white-space inserted around server-rendered markup.' ,
517+ ) ;
518+ }
519+ }
520+ container . removeChild ( rootSibling ) ;
504521 }
505522 }
506523 const newRoot = DOMRenderer . createContainer ( container ) ;
You can’t perform that action at this time.
0 commit comments