reactjstypescripteslinttypescript-eslintradix-ui

Radix UI type error when trying to "react-accordion"


I am trying to import react accordion root component and then export it back in my project while renaming it as Accordion but currently i receive type error Unsafe assignment of an `any` value
Not sure how to fix it as i already tried forcing types with as

import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { cn } from "@/lib/utils";

const Accordion = AccordionPrimitive.Root;

enter image description here
PS- I don't want to disable this eslint rule


Solution

  • import * as React from "react";
    import * as AccordionPrimitive from "@radix-ui/react-accordion";
    import { cn } from "@/lib/utils";
    
    type AccordionProps = React.ComponentProps<typeof AccordionPrimitive.Root>;
    
    const Accordion: React.FC<AccordionProps> = AccordionPrimitive.Root;
    
    export { Accordion };