Composition
You can add components within the body of another component. Composition enables you to build complex components from simpler building-block components.
Inheritance is allowed, but it isn’t recommended because composition is usually more effective. To share logic between components, use a module that contains only logic. See Additional JavaScript Files. If you do choose to use inheritance, note that it doesn’t work across namespaces under Lightning Locker. You must enable LWS to use inheritance across namespaces. You can’t extend the lightning
namespace in either security architecture.
When composing components, a template owner can nest components inside of a container component. The container component is known as the parent component, and each of the nested components are called child components. See Compose Components.
Additionally, a parent component can:
- Set properties on children
- Call methods on children
- Spread properties on children
- Pass markup into slots
To check your component dependencies in an org, see View Component Dependencies.
See Also
- Compose Components Using Slots Vs Data
- Lightning Web Components Video Gallery: Parent-Child Components