refactor: userpreferences are now in the DB
This commit is contained in:
28
hooks/useDragAndDrop.ts
Normal file
28
hooks/useDragAndDrop.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useSensors, useSensor, PointerSensor } from '@dnd-kit/core';
|
||||
|
||||
/**
|
||||
* Hook pour gérer le drag & drop de manière safe avec SSR
|
||||
* Désactive le DnD jusqu'à l'hydratation pour éviter les erreurs d'hydratation
|
||||
*/
|
||||
export function useDragAndDrop() {
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
// Activer le drag & drop après l'hydratation
|
||||
setIsMounted(true);
|
||||
}, []);
|
||||
|
||||
const sensors = useSensors(
|
||||
useSensor(PointerSensor, {
|
||||
activationConstraint: {
|
||||
distance: 8,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
return {
|
||||
isMounted,
|
||||
sensors
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user