Is it ok I put random things in div.root?
See original GitHub issueCan I put some initial text in div.root element? (eg. p tag with text, div, canvas…)
Because I saw many people put their entire rendered markup in div.root to hack seo.
So when
ReactDOM.render( <App />, document.getElementById('root'));
What will happen with div.root? Is it’s childNode all being erased?
If it is, then I can put random things in it, am I right?
Thank for your patience!!
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Why do we use <div>#root instead of <body>? - Stack Overflow
In the cases where that is happening it's often because they are adding something that needs to be rendered, which means it has...
Read more >Stop using so many divs! An intro to semantic HTML
First and foremost, it's almost definitely fine! The point here isn't to totally get rid of <div> s, it's to stop using them...
Read more >Bounce Element Around Viewport in CSS - CSS-Tricks
Then I want the elements to bounce around viewport randomly. The problem is that positioning interferes with the @keyframes animation and ...
Read more >The Perils of Rehydration - Josh W Comeau
Server-side rendering can be a performance win, but the thing is, that work still needs to be done on-demand. When you request your-website.com, ......
Read more >Material UI (MUI) Box component vs div : r/reactjs - Reddit
it would render the same thing, yes, but not compile down. compilation is a build-time thing and it doesn't have implications on runtime ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Most search engine crawlers have no problem parsing client-rendered applications, but you can definitely send down rendered markup using
ReactDOMServer
.You can feel free to put whatever you want inside the root container, as React will simply clear out any child nodes before rendering.
https://github.com/facebook/react/blob/1fd205ad2d101f441622c9bb7e2ccb480281e0a0/packages/react-dom/src/client/ReactDOM.js#L1002-L1023
If you did server rendering with
ReactDOMServer
you would instead use[ReactDOM.hydrate](https://reactjs.org/docs/react-dom.html#hydrate)
, which would avoid the cost of throwing away all the markup and starting from scratch.@aweary Thank you very much!!