Dynamically render LWC child component (works on LWC Open source)

OmkarDeokar
Jan 27, 2021

--

To render child component dynamically inside your LWC component, you can use the render() lwc lifecycle hook.

But in this topic we will see how to render lwc dynamically on run time without render hook.

Parent component

Parent component will have a lazy loader to dynamically create component at run time.

The enclosing tag “x-lazy”
can be anything like
“boatyMcBoatFace” we don’t care on that part

Parent JS controller

The track variable “customCtor” can be decided at run time.

Note: As of this writing, this feature is not available on salesforce platform, can be used only in LWC open source for now.

--

--

OmkarDeokar
OmkarDeokar

Written by OmkarDeokar

Making world a better place…blah…blah

No responses yet