Replace <body> content
See original GitHub issueDo you want to request a feature or report a bug? feature
What is the current behavior?
When I use render() to replace the body content I got a warning message:
Warning: render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.
But if I’m creating a whole website, according to:
https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Document_and_website_structure
It is better to have the <header>
<main>
<footer>
elements, and these elements are said to be better directly under body
For example, it says:
<main>
is for content unique to this page. Use <main>
only once per page, and put it directly inside <body>.
Ideally this shouldn’t be nested within other elements.
So I think this is a common case to replace the whole content of the <body>
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn’t have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
What is the expected behavior? Maybe remove the warning?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? “react-dom”: “^16.3.0”,
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:5 (3 by maintainers)
Is there any way to come up with
semantic HTML structure
in React !?without any side effect !
Thanks But I also would like to render
<header>
and<footer>
. So I’d better put them inside<main>
?