Files
towercontrol/src/hooks/useDragAndDrop.ts
Julien Froidefond 4152b0bdfc chore: refactor project structure and clean up unused components
- Updated `TODO.md` to reflect new testing tasks and final structure expectations.
- Simplified TypeScript path mappings in `tsconfig.json` for better clarity.
- Revised business logic separation rules in `.cursor/rules` to align with new directory structure.
- Deleted unused client components and services to streamline the codebase.
- Adjusted import paths in scripts to match the new structure.
2025-09-21 10:26:35 +02:00

29 lines
642 B
TypeScript

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
};
}