Skip to content

Refactor: Migrate class components to hooks, standardize props, and add ESLint#5

Merged
TamimEhsan merged 14 commits into
masterfrom
refactor-codebase
May 25, 2026
Merged

Refactor: Migrate class components to hooks, standardize props, and add ESLint#5
TamimEhsan merged 14 commits into
masterfrom
refactor-codebase

Conversation

@TamimEhsan
Copy link
Copy Markdown
Owner

  • Convert all class components to functional components with hooks — every visualizer (N-Queen, Convex Hull, Pathfinder, Sorting, Recursive Sorting, Turing Machine, Prime Numbers, Recursion Tree, Binary Search) now uses useState, useEffect, and useRef. Uses useRef for values read inside async animation loops to avoid stale closure bugs. 15-Puzzle is the only remaining class component (intentionally skipped).
  • Standardize disabled prop naming — replaced disable and isDisabled variants with the standard disabled across all menu components and shared UI. Added visual disabled state to the Slider component.
  • Add ESLint with next/core-web-vitals flat config (eslint.config.mjs). Rules: no-console (warn), no-unused-vars (warn), react/no-unescaped-entities (off). All lint errors resolved.
  • Remove unused variables and dead code — deleted dead functions, unused imports, unreferenced props, and removed unused files (cnvas2.jsx, timer.jsx, details.jsx, vertexOriginal.jsx).
  • Add About page and update Navbar with Info link.
  • Add running state management — disable controls during animations across all visualizers.

TamimEhsan added 14 commits May 25, 2026 12:23
Migrates cell, cells, menu, and page components to use useState, useEffect,
and useRef. Uses refs for speed and number values read inside async algorithm.
…h hooks

Migrates menu, canvas, and page to use useState, useEffect, and useRef.
Removes unused cnvas2.jsx and timer.jsx.
… hooks

Migrates node, grid, menu, and page components. Uses useRef for isRunning
guard in async animations. Removes unused state and commented-out code.
Sorting: menu with useState for compareMode, page with useRef for speed
and dual running state tracking via refs.
Recursive Sorting: rect, menu, page converted. Three async animation
handlers (merge, heap, quick) use speedRef and countRef.
Also fixes CustomSlider to accept disabled prop alongside disable/isDisabled.
…onents

Converts Turing Machine, Prime Numbers, Recursion Tree, and Binary Search
to use useState, useEffect, and useRef. Uses refs for values read inside
async animation loops. Removes unused dead files (details.jsx,
vertexOriginal.jsx). Cleans up console.logs and commented-out code.
Unifies CustomSlider to accept only 'disabled' (removes disable/isDisabled).
Cleans up commented code and imports in CustomSelect and CustomToggle.
Adds visual disabled state (opacity + pointer-events) to Slider component.
Fixes Turing Machine midCell ref sync in shift handlers.
Set up ESLint using eslint-config-next v16 native flat config with
no-console (warn), no-unused-vars (warn), and react/no-unescaped-entities (off).
Remove unused vars, dead functions (sib, dfs, handleRefresh), unused
imports, and unused props to resolve all ESLint no-unused-vars warnings.
Also fix setState-in-effect, state mutation, and hoisting lint errors.
Recursion tree: replace double-border nodes with single border, drop
shadow, and three-state coloring (amber=active, teal=partial, slate=completed).
Soften edge/arrow colors to slate-500.

Pathfinder: fix bug where visited cell colors disappeared when shortest
path was animated (stale grid closure).

Update REFACTOR.md to reflect completed tasks.
@TamimEhsan TamimEhsan merged commit 7270842 into master May 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant