mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
26 lines
634 B
TypeScript
26 lines
634 B
TypeScript
import React, { useState, useEffect } from "react";
|
|
// react beautiful dnd
|
|
import { Droppable } from "react-beautiful-dnd";
|
|
import type { DroppableProps } from "react-beautiful-dnd";
|
|
|
|
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>;
|
|
};
|
|
|
|
export default StrictModeDroppable;
|