Type 'MutableRefObject<Element>' is not assignable to type 'LegacyRef<HTMLDialogElement> | undefined'.
V-iktor opened this issue · comments
This example is not working in Typescript 5 with React 18
I was able to solve this issue by explicitly specifying the type of useClickAway
like this:
const ref = useClickAway<HTMLDialogElement>(() => {
...
})
The same goes for other elements as well. If you want to reference, for example, a div
, you should specify <HTMLDivElement>