Current Issues with useDrawing.ts (713 lines):
- Handles all drawing functionality in one massive hook.
- Complex state management for preview, validation, and completion.
- Mixed drawing logic with UI state management.
- Performance-critical code mixed with business logic.
Recommended Modularization Structure:
drawing/
├── index.ts (main hook)
├── hooks/
│ ├── useDrawingState.ts
│ ├── useDrawingPreview.ts
│ ├── useDrawingValidation.ts
│ └── useDrawingCompletion.ts
├── services/
│ ├── DrawingPreviewService.ts
│ ├── DrawingValidationService.ts
│ └── SnapService.ts
└── utils/
├── drawingCalculations.ts
└── drawingHelpers.ts
Actionable Steps:
- Extract state, preview, validation, and completion logic into separate hooks under
hooks/.
- Move preview, validation, and snapping logic into dedicated services.
- Refactor calculations and helpers into
utils/.
- Use
index.ts as the main hook orchestrator that composes these modules.
- Gradually migrate logic from
useDrawing.ts into new modules for improved maintainability and performance.
Current Issues with
useDrawing.ts(713 lines):Recommended Modularization Structure:
Actionable Steps:
hooks/.utils/.index.tsas the main hook orchestrator that composes these modules.useDrawing.tsinto new modules for improved maintainability and performance.