Skip to content
Discussion options

You must be logged in to vote

There are a few ways of doing this compound component pattern:

  • either you attach the parts statically to the root component (that has potential issues with tree-shaking if some of the parts are optional for example, as the users will more than likely incur the weight of that code anyway as it's attached to the root)
  • what we do in Radix is because we have separate packages, we expose the parts as separate components, and make use of import * as … pattern (we also export them named, but that's kinda irrelevant here)

Take a look at this example:

const Root = Avatar;
const Image = AvatarImage;
c…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@lsy0xcc
Comment options

@joaom00
Comment options

@lsy0xcc
Comment options

@joaom00
Comment options

@lsy0xcc
Comment options

Answer selected by lsy0xcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants