Is there a particular reason why the initial create-react-app index.html file and index.js file construct it so that the application root is rendered into a #root element rather than the body directly?
I can understand keeping the React application at a lower level for applications which run multiple view layers within the same document, but for an app delivered solely by React the #root element seems like a redundant DOM node.
Chris
If you render directly into document.body
, you risk collisions with scripts that do something with it (e.g. Google Font Loader or third party browser extensions) which produce very weird and hard to debug errors in production. React warns you if you attempt to do this.
Most helpful comment
If you render directly into
document.body
, you risk collisions with scripts that do something with it (e.g. Google Font Loader or third party browser extensions) which produce very weird and hard to debug errors in production. React warns you if you attempt to do this.