Skip to content
Discussion options

You must be logged in to vote

Hey @williamlmao,

You don't really need that Inner component, it doesn't achieve anything.
You could something like this instead:

type RootElement = React.ElementRef<typeof AvatarPrimitive.Root>;
type RootProps = React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> & {
  ignoreDefaultStyles?: boolean;
};

const Root = React.forwardRef<RootElement, RootProps>((props, forwardedRef) => {
  const { className, ignoreDefaultStyles, ...rest } = props;
  return (
    <AvatarPrimitive.Root
      {...rest}
      ref={forwardedRef}
      className={cn(
        {
          'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full':
            !ignoreDefaultStyles,
        },
        clas…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@williamlmao
Comment options

@joaom00
Comment options

@benoitgrelard
Comment options

@williamlmao
Comment options

Answer selected by williamlmao
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