Compound components enable greater flexibility and modularity, at the cost of a slightly added complexity for the consumer.
One of the most frequent mistakes that we witness is when consumers render a subcomponent outside of its compound component's "context" — for example, rendering a Composite.Item without nesting it under a Composite item.
While we want to help consumers in several ways, including proving better documentation and examples, one (complementary) approach is to have compound components throw when they are not rendered inside the relative top-level component.
We should, therefore, implement this standard behaviour across all compound components in the @wordpress/components library:
Compound components enable greater flexibility and modularity, at the cost of a slightly added complexity for the consumer.
One of the most frequent mistakes that we witness is when consumers render a subcomponent outside of its compound component's "context" — for example, rendering a
Composite.Item
without nesting it under aComposite
item.While we want to help consumers in several ways, including proving better documentation and examples, one (complementary) approach is to have compound components throw when they are not rendered inside the relative top-level component.
We should, therefore, implement this standard behaviour across all compound components in the
@wordpress/components
library:BaseControl
Composite
CustomSelectControl
(internal implementation)ItemGroup
Menu
Tabs
ToggleGroupControl
Toolbar