I have some code like
const ParentComponent = () => {
let child = <ChildComponent {...props} />;
if (condition) {
const parent = document.GetElementById("parentId");
//Here is a problem
parent.appendChild(child);
}
return (
<>
<div id="parentId"></div>
</>
);
};
export default ParentComponent;
const ChildComponent = () => {
return (
<>
<div></div>
</>
);
};
export default ChildComponent;
I want to dynamically add child components multiple times but getting an error 
I am happy to do it in any way using Javascript or useRef. Thanks!
document.GetElementById(it should be lowercase 'g', (2) you are not waiting for the virtual DOM to be rendered (and be available in the real DOM) before appending it. SeeuseEffect.