We have purposely made the decision of not allowing dynamic component creation (the equivalent of $A.createComponent) to make sure we had a clean, statically analyzable and predictable behavior on which to build upon.

Since the question of dynamic component creation came a bunch of times, I want to share an example of a bug that currently came to Aura long time ago that shows precisely why we decided to block it.

A "simple" example of dynamic component creation:


    ({ 
    createComponent: function (component, facet, componentDef, fieldPath, attributes) { 
       // componentDef is a basic component: ex. markup://lightning:textarea
        $A.createComponent(componentDef, attributes, callback); 
        function callback(newComponent, status, errorMessage) { 
            if (status === "SUCCESS") { 
                newComponent.addValueHandler({ 
                    value: "v.value",
                    event: "change",
                    globalId: component.getGlobalId(),
                     
                    method: function (event) { 
                        var record = component.get("v.record"); 
                        var value = event.getParam("value"); 
                    } 
                }); 
                newComponent.set("v.name", fieldPath); 
                facet.push(newComponent); 
            } 
        } 
    } 
    })

Dynamic component creation should only be used in cases where you are loading a completely big, different, disconnected tree.

Does webpack route splitting sound familiar? Thats a common pattern in the industry to lazy load or preload components. But you render the whole subtree based on the route! Everything else is completely predictable down the tree.


Are there other valid use-cases? Absolutely, but 99% of the use cases fall into the declarative predictable category, rather than the dynamic craziness.


And thats why in LWC we don't allow you to shot yourself in the foot creating small tiny components, and once we do, we will give you a water pistol first :), which means we will make it as predictable, restricted and side-effect free as possible.

Once we do allow it it will be very well documented and we will make sure we can still preserve as much as possible the invariants described above.