Skip to content

Commit eb7d9bc

Browse files
authored
fix: prevent dnd hydration errors (#210)
1 parent bccf5d4 commit eb7d9bc

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ChessboardProvider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ export function ChessboardProvider({
312312
// the animation timeout whilst waiting for animation to complete
313313
const animationTimeoutRef = useRef<NodeJS.Timeout | null>(null);
314314

315+
// unique id for dnd context, we need this to prevent hydration issues
316+
const dndId = `dnd-${id}`;
317+
315318
// if the position changes, we need to recreate the pieces array
316319
useEffect(() => {
317320
const newPosition =
@@ -681,6 +684,7 @@ export function ChessboardProvider({
681684
onDragEnd={handleDragEnd}
682685
onDragCancel={handleDragCancel}
683686
sensors={sensors}
687+
id={dndId}
684688
>
685689
{children}
686690
</DndContext>

0 commit comments

Comments
 (0)