2022-11-19 14:21:26 +00:00
|
|
|
import React, { useState, useEffect } from "react";
|
2023-02-06 09:48:57 +00:00
|
|
|
|
2022-11-19 14:21:26 +00:00
|
|
|
// react beautiful dnd
|
2023-01-26 18:12:20 +00:00
|
|
|
import { Droppable, DroppableProps } from "react-beautiful-dnd";
|
2022-11-19 14:21:26 +00:00
|
|
|
|
|
|
|
const StrictModeDroppable = ({ children, ...props }: DroppableProps) => {
|
|
|
|
const [enabled, setEnabled] = useState(false);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const animation = requestAnimationFrame(() => setEnabled(true));
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
cancelAnimationFrame(animation);
|
|
|
|
setEnabled(false);
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
2023-02-06 09:48:57 +00:00
|
|
|
if (!enabled) return null;
|
2022-11-19 14:21:26 +00:00
|
|
|
|
|
|
|
return <Droppable {...props}>{children}</Droppable>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default StrictModeDroppable;
|