Create-react-app: Question: Top level ReactDOM.render() into body rather than a 'root' element

Created on 15 Feb 2017  路  1Comment  路  Source: facebook/create-react-app

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

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fson picture fson  路  3Comments

jnachtigall picture jnachtigall  路  3Comments

oltsa picture oltsa  路  3Comments

fson picture fson  路  3Comments

stopachka picture stopachka  路  3Comments