How to appendChild custom component using React JS and Typescript?

I have some code like

const ParentComponent=()=>{
let child=<ChildComponent (...props) />
      const parent=document.GetElementById('parentId');
//Here is a problem
    return <>
<div id="parentId"></div>
export default ParentComponent;

const ChildComponent=()=>{
 return <>
export default ChildComponent;

I want to dynamically add child components multiple times but getting an error enter image description here

I am happy to do it in any way using Javascript or useRef.

Source: JavaSript – Stack Overflow

November 28, 2021
Category : News
Tags: DOM | javascript | jsx | reactjs

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.