Warn when mounting into document.body
Andrew Clark committed
Feb 1, 2017 at 17:56 UTC
d47c21589b1bf63cc93866aaba644dbc245904a5
1 file changed
+11
src/renderers/dom/fiber/ReactDOMFiber.js
+11
@@ -385,6 +385,17 @@ var ReactDOM = {
385
);
386
}
387
388
+ if (__DEV__) {
389
+ warning(
390
+ !container.tagName || container.tagName.toUpperCase() !== 'BODY',
391
+ 'render(): Rendering components directly into document.body is ' +
392
+ 'discouraged, since its children are often manipulated by third-party ' +
393
+ 'scripts and browser extensions. This may lead to subtle ' +
394
+ 'reconciliation issues. Try rendering into a container element created ' +
395
+ 'for your app.'
396
+ );
397
+ }
398
+
399
return renderSubtreeIntoContainer(null, element, container, callback);
400
},
401