Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// StrictModeDroppable.tsx
// Credits to https://github.com/GiovanniACamacho and https://github.com/Meligy for the TypeScript version
// Original post: https://github.com/atlassian/react-beautiful-dnd/issues/2399#issuecomment-1175638194
/**
 * This component is necessary because the Droppable component exported by the react-beautiful-dnd
 * library does not work when using React in StrictMode. Hence this component is a workaround.\
 * */
 
/**
 * libraries
 */
import { useEffect, useState } from "react";
import { Droppable, type 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);
    };
  }, []);
  if (!enabled) {
    return null;
  }
  return <Droppable {...props}>{children}</Droppable>;
};