When using react-dnd version 16 with TypeScript in Next.js, the refs within the return array of the useDrag and useDrop hooks are not compatible with LegacyRef. Interestingly, other platforms like Vite.Js handle this type assignment correctly.
The same code works on both platforms, but Next.js throws a type error.
const [{ isDragging }, dragRef] = useDrag(() => ({
...
}));
<div ref={dragRef}>
....
</div>
Even attempting to cast it does not solve the issue. How can I resolve this type error?
Error: Type 'ConnectDragSource' is not assignable to type 'LegacyRef | undefined'.