Why only one component can be render at root div?
See original GitHub issueI called two render methods to same root div .
RenderDOM.render( < Navigation /> ,document.getElementById(' root '));
RenderDOM.render( < App /> ,document.getElementById(' root '));
And what i get rendered on my screen is only a App component. Just want to know that the one render method override the previous render method?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Why can components only return one node in ReactJS? (Is ...
Currently, in a component's render, you can only return one node; if you have, say, a list of divs to return, you must...
Read more >Rendering Elements - React
Rendering an Element into the DOM We call this a “root” DOM node because everything inside it will be managed by React DOM....
Read more >How to Use One Component to Render Many HTML ...
Before React 16.2, you could render only a single DOM node inside the render method. Now you can render multiple DOM nodes.
Read more >How to Easily Render Multiple Elements in React - ITNEXT
In Vue and React, we can only render one element. Even if we have multiple elements to render, there can only be a...
Read more >Why does react only allow one DOM element to be rendered?
InnerHTML requires a root element and in many implementations requires the provided html to be a structurally complete snippet. Structurally complete requires ...
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
To clarify: the original question seems to be why the following code only ends up showing
App
rather than bothNavigation
andApp
.The answer is that the second call to
render
replaces the first. If you want to render bothNavigation
andApp
, then you should render them both in the same call using either a “fragment” or an array:Hope this helps!
Seems like this issue has been answered now?