I have to render React component on multiple places across the page. So I have two divs
with same ids
and I want to render same React component on both places:
<h1>Title 1</h1>
<div id='react-component'>/<div>
.
.
.
<h1>Title 2</h1>
<div id='react-component'>/<div>
In React it renders component nly on one place:
const node = document.querySelector('#react-component');
if (!node) {
return null;
}
ReactDOM.render(<Component />, node);
What would be the most efficient way to solve this? Is it possible for ReactDOM
to render same component on multiple nodes?