To create nested components in pure JS, we can follow the below approach:
index.tsx331 chars14 linesindex.tsx182 chars10 linesupdate() function within the child component.index.tsx252 chars14 linesNow, we can instantiate the parent component and render it to the desired parent DOM element as shown below:
index.tsx144 chars5 lines
To update the DOM element of the child component, we can simply invoke the update() function of the child component as shown below:
index.tsx136 chars5 lines
This will update the child DOM element from "Hello World!" to "New Text!".
gistlibby LogSnag