diff --git a/.changeset/violet-oranges-teach.md b/.changeset/violet-oranges-teach.md new file mode 100644 index 0000000000..56404746a1 --- /dev/null +++ b/.changeset/violet-oranges-teach.md @@ -0,0 +1,5 @@ +--- +"@nextui-org/react-utils": patch +--- + +refactored the assignRef function to remove @ts-ignore and properly handle reference assignment using MutableRefObject diff --git a/packages/utilities/react-utils/src/refs.ts b/packages/utilities/react-utils/src/refs.ts index ece6fa754c..5fb8c24539 100644 --- a/packages/utilities/react-utils/src/refs.ts +++ b/packages/utilities/react-utils/src/refs.ts @@ -1,5 +1,6 @@ import * as React from "react"; import {isFunction} from "@nextui-org/shared-utils"; +import {MutableRefObject} from "react"; export type ReactRef = React.RefObject | React.MutableRefObject | React.Ref; @@ -19,8 +20,7 @@ export function assignRef(ref: ReactRef | undefined, value: T) { } try { - // @ts-ignore - ref.current = value; + (ref as MutableRefObject).current = value; } catch (error) { throw new Error(`Cannot assign value '${value}' to ref '${ref}'`); }