Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility issue with React 19 #3295

Open
mariangle opened this issue Dec 18, 2024 · 2 comments
Open

Compatibility issue with React 19 #3295

mariangle opened this issue Dec 18, 2024 · 2 comments

Comments

@mariangle
Copy link

Bug report

Current Behavior

image

Expected behavior

Ive migrated to Next.js 15, and its a little annoying getting the console error above. Im using ShadCN for my slider which uses radix. Ive changed the old React.ElementRef to React.ComponentRef

Reproducible example

"use client";

import * as React from "react";
import * as SliderPrimitive from "@radix-ui/react-slider";

import { cn } from "@/lib/utils/cn";

interface SliderProps extends React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> {
  thumbStyle?: React.CSSProperties;
  trackStyle?: React.CSSProperties;
  rangeStyle?: React.CSSProperties;
}

const Slider = React.forwardRef<React.ComponentRef<typeof SliderPrimitive.Root>, SliderProps>(
  ({ className, disabled, thumbStyle, trackStyle, rangeStyle, ...props }, ref) => (
    <SliderPrimitive.Root
      ref={ref}
      className={cn(
        "relative flex w-full touch-none select-none items-center",
        className,
        disabled && "pointer-events-none opacity-50"
      )}
      {...props}
    >
      <SliderPrimitive.Track
        className="relative h-2 w-full grow overflow-hidden rounded-full bg-muted"
        style={trackStyle}
      >
        <SliderPrimitive.Range className="absolute h-full bg-primary/75" style={rangeStyle} />
      </SliderPrimitive.Track>
      <SliderPrimitive.Thumb
        className="block size-4 rounded-full border bg-white transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 dark:border-none"
        style={thumbStyle}
      />
    </SliderPrimitive.Root>
  )
);

Slider.displayName = SliderPrimitive.Root.displayName;

export { Slider };

Suggested solution

Additional context

Ive just upgrade to Next.js 15 and React 19 and having issues with my ui components which uses radix.

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-slider 1.1.2
React n/a 19.0.0
Browser Chrome
Assistive tech
Node n/a v18.18.0
npm/yarn npm 10.3.0
Operating System Win 10
@arniu
Copy link

arniu commented Dec 19, 2024

Would you like to upgrade all the components according to the official guide React 18 to 19 Migration?

@AhmedAdel991
Copy link

Can't we also remove the forwardRef as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants