Skip to content

React 19 compatibility #57

Open
Open
@anthony2261

Description

@anthony2261

Great component! Strange that it's not part of shadcn.

I added this to my project which uses React 19, tailwind v4, etc.. and had an issue: forwardRef is deprecated in React 19, you can just pass the ref as a prop now!

Here's what worked for me:

interface MultiSelectProps
  extends React.ButtonHTMLAttributes<HTMLButtonElement>,
    VariantProps<typeof multiSelectVariants> {
  // ...
  ref: React.RefObject<HTMLButtonElement>;
}


export const MultiSelect: React.FC<MultiSelectProps> = ({  // used FC type
  options,
  onValueChange,
  variant,
  defaultValue = [],
  placeholder = "Select options",
  animation = 0,
  maxCount = 3,
  modalPopover = false,
  asChild = false,
  className,
  ref,  // passed as a prop
  ...props
}) => {
  const [selectedValues, setSelectedValues] =
    React.useState<string[]>(defaultValue);
  // ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions