{"id":48480908,"url":"https://github.com/vladyslav-panchenko280/debug-custom-hooks-in-react","last_synced_at":"2026-04-07T08:07:11.719Z","repository":{"id":336195923,"uuid":"1148320765","full_name":"vladyslav-panchenko280/debug-custom-hooks-in-react","owner":"vladyslav-panchenko280","description":"A React + TypeScript app with intentional bugs in custom hooks.  Practice debugging with StrictMode, useDebugValue, and React DevTools.  Includes 4 real-world bugs: race conditions, stale closures, missing dependencies, and unstable references.","archived":false,"fork":false,"pushed_at":"2026-02-03T13:01:08.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-03T20:52:36.546Z","etag":null,"topics":["debugging","frotnend","react","react-devtools","react-training","strict-mode","tutorial","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vladyslav-panchenko280.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-02T20:39:43.000Z","updated_at":"2026-02-03T13:02:26.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/vladyslav-panchenko280/debug-custom-hooks-in-react","commit_stats":null,"previous_names":["vladyslav-panchenko280/debug-custom-hooks-in-react"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/vladyslav-panchenko280/debug-custom-hooks-in-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladyslav-panchenko280%2Fdebug-custom-hooks-in-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladyslav-panchenko280%2Fdebug-custom-hooks-in-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladyslav-panchenko280%2Fdebug-custom-hooks-in-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladyslav-panchenko280%2Fdebug-custom-hooks-in-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladyslav-panchenko280","download_url":"https://codeload.github.com/vladyslav-panchenko280/debug-custom-hooks-in-react/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladyslav-panchenko280%2Fdebug-custom-hooks-in-react/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31504899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugging","frotnend","react","react-devtools","react-training","strict-mode","tutorial","typescript"],"created_at":"2026-04-07T08:07:11.647Z","updated_at":"2026-04-07T08:07:11.711Z","avatar_url":"https://github.com/vladyslav-panchenko280.png","language":"TypeScript","readme":"# Pizza Debug Shop\n\nA small React + TypeScript app with **intentional bugs** in custom hooks for debugging practice.\n\n## Setup\n\n```bash\nnpm install\nnpm run dev\n```\n\n## Debug Tools\n\n| Tool | Purpose |\n|------|---------|\n| **React DevTools** | Inspect hooks, components, useDebugValue output |\n| **StrictMode** | Double-invokes effects to catch side-effect bugs |\n| **useDebugValue** | Custom labels in DevTools for hooks |\n| **Console** | Watch for warnings, repeated logs |\n| **Profiler** | Detect unnecessary re-renders |\n\n## Bugs to Find\n\n### Bug #1: Race Condition (usePizzaMenu)\n- **Location**: `src/hooks/usePizzaMenu.ts`\n- **Symptom**: Data fetches twice in StrictMode\n- **Tool**: Console, StrictMode\n- **Hint**: Missing cleanup in useEffect\n\n### Bug #2: Stale Closure (useCart)\n- **Location**: `src/hooks/useCart.ts`\n- **Symptom**: Adding same pizza rapidly doesn't increment correctly\n- **Tool**: React DevTools, rapid clicking\n- **Hint**: Check useCallback dependencies\n\n### Bug #3: Missing Dependency (useLocalStorage)\n- **Location**: `src/hooks/useLocalStorage.ts`\n- **Symptom**: Changing storage key doesn't save to correct key\n- **Tool**: DevTools, localStorage inspection\n- **Hint**: useEffect dependency array\n\n### Bug #4: Unstable Reference (usePizzaOrder)\n- **Location**: `src/hooks/usePizzaOrder.ts`\n- **Symptom**: Console spam \"Order hook effect running\"\n- **Tool**: Console, Profiler\n- **Hint**: Array reference in dependency\n\n## Tasks Checklist\n\n### Part 1: Setup \u0026 Explore\n- [ X ] Install React DevTools browser extension\n- [ X ] Run the app with `npm run dev`\n- [ X ] Open DevTools → Components tab\n- [ X ] Find `useDebugValue` output for each hook\n\n### Part 2: StrictMode Investigation\n- [ X ] Watch console on page load\n- [ X ] Notice double effect execution\n- [ X ] Try removing `\u003cStrictMode\u003e` from main.tsx\n- [ X ] Compare behavior with/without StrictMode\n\n### Part 3: Find \u0026 Fix Bugs\n- [ X ] **Bug #1**: Add cleanup to usePizzaMenu\n- [ X ] **Bug #2**: Fix useCallback in useCart\n- [ X ] **Bug #3**: Add missing dependency in useLocalStorage\n- [ X ] **Bug #4**: Stabilize reference in usePizzaOrder\n\n### Part 4: Verify Fixes\n- [ X ] No double fetches with StrictMode\n- [ X ] Rapid add-to-cart works correctly\n- [ X ] No console spam from order hook\n\n## Learning Goals\n\n1. Understand StrictMode double-invoke behavior\n2. Use useDebugValue for hook inspection\n3. Identify stale closures in callbacks\n4. Handle async cleanup properly\n5. Stabilize object/array dependencies\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladyslav-panchenko280%2Fdebug-custom-hooks-in-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladyslav-panchenko280%2Fdebug-custom-hooks-in-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladyslav-panchenko280%2Fdebug-custom-hooks-in-react/lists"}