enable strict mode and fixing the Droppable issue

This commit is contained in:
daniel31x13
2024-02-26 22:29:23 -05:00
parent cc02ab3615
commit 4ff7298a3b
4 changed files with 22 additions and 45 deletions
+1 -1
View File
@@ -8,8 +8,8 @@ import {
DragDropContext,
Draggable,
DraggableProvided,
Droppable,
} from "react-beautiful-dnd";
import { StrictModeDroppable as Droppable } from "./StrictModeDroppable";
type Props = {
links: boolean;
+19
View File
@@ -0,0 +1,19 @@
// StrictModeDroppable.tsx
import { useEffect, useState } from "react";
import { Droppable, DroppableProps } from "react-beautiful-dnd";
export const StrictModeDroppable = ({ children, ...props }: DroppableProps) => {
const [enabled, setEnabled] = useState(false);
useEffect(() => {
const animation = requestAnimationFrame(() => setEnabled(true));
return () => {
cancelAnimationFrame(animation);
setEnabled(false);
};
}, []);
if (!enabled) {
return null;
}
return <Droppable {...props}>{children}</Droppable>;
};