You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: Add info to create compound component regarding createComponent (Workday#3057)
Add docs around `createContainer` vs `createComponent` in the `create compound component` section in our docs.
[category:Documentation]
Co-authored-by: manuel.carrera <[email protected]>
Co-authored-by: @NicholasBoll <[email protected]>
In most cases you'll create compound components that have a model and share information across subcomponents. However, in the case where information doesn't need to be shared, you can create a non
22
+
coordinated component. These components often represent some styled element with no associated role
23
+
or behavior and don't rely on state and events such as a `Card`, `Flex` or `Button` components. Use
24
+
`createComponent` factory function in these scenarios.
25
+
26
+
### `createComponent`
27
+
28
+
Use `createComponent` when you want to create a rendered element with _no behavior_. This is useful
29
+
for elements that you want to use for styling purposes like container elements, or subcomponents
30
+
that are simple rendered elements. This utility function will wrap your component in a
31
+
`React.ForwardRef` and allow you to add subcomponents as well.
32
+
33
+
```tsx
34
+
exportconst Card =createComponent('div')({
35
+
displayName: 'Card',
36
+
subComponents: {
37
+
Heading: CardHeading, // this is also using createComponent
0 commit comments