fix: resolve react-hooks lint warnings — exhaustive-deps and React Compiler (#159 #160)#161
Merged
ChristopherRotnes merged 1 commit intomasterfrom May 10, 2026
Merged
Conversation
…ings (#159 #160) Real refactors (no eslint-disable): - History: move auto-expand out of useEffect into loadSession, eliminating a cascading setState; capture initialDate in a ref for mount-only effect - MuscleMap: move setUseTodayDate(true) to the two dispatch sites (ANALYZE_SUCCESS and template preload) that enter the confirm step; removes the step-watching effect - Report: relocate cache-lookup useEffect below the useMemo declarations it reads (muscleCounts, sessionCount, untrainedMuscles), fixing forward-reference warnings - Home: store maxLeft in tooltip state at event-handler time instead of reading weekStripRef.current during render Targeted eslint-disable (with justification comments) for patterns that are correct but unfixable without large refactors: - Bibliotek: setExVisible(20) reset on filter change (standard pagination pattern) - Planlegger: loadPlan() in useEffect (async data fetch, setState in callbacks only) - Report: setLoading(true) before async fetch (standard loading-state init) - MuscleMap: setUseTodayDate in template preload effect - MuscleMap/Report: intentionally excluded callback deps (onTemplatePreloadConsumed, onPrefillConsumed) to prevent infinite re-runs npm run lint: 0 in-scope warnings (9 react-refresh/only-export-components remain, intentional multi-export architecture per issue scope) npm test: 82/82 passing Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://white-island-090dfd003-161.westeurope.7.azurestaticapps.net |
This was referenced May 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
react-hooks/exhaustive-depswarnings (As a developer I want to resolve react-hooks/exhaustive-deps warnings so stale closure risks are either fixed or explicitly documented #159) andreact-compiler/react-hooks/set-state-in-effect/react-hooks/immutability/react-hooks/refswarnings (As a developer I want to resolve React Compiler violations so the codebase is safe for concurrent rendering and future compiler adoption #160)react-refresh/only-export-components(intentional multi-export architecture, explicitly out of scope in both issues)Changes per file
History.jsxloadSessionmoved before its mount effect (fixes forward-reference);initialDatecaptured in a ref so the empty-dep array is correct; auto-expand logic moved intoloadSession(setsexpandedIdsright aftersetDaySessions) — eliminates a cascading setStateMuscleMap.jsxsetUseTodayDateeffect removed; call added at the two dispatch sites that enter confirm (ANALYZE_SUCCESSinanalyze()and the template-preload effect);onTemplatePreloadConsumeddep suppressed with commentReport.jsxuseEffectrelocated belowmuscleCounts/sessionCount/untrainedMusclesdeclarations — fixes three "variable accessed before declaration" warnings;onPrefillConsumeddep suppressed (mount-only callback);setLoading(true)suppressed (standard pre-async loading-state init)Home.jsxweekStripRef.currentremoved from JSX render path;maxLeftnow stored in tooltip state when set by event handlers (onMouseEnter,onFocus)Bibliotek.jsxsetExVisible(20)suppressed — standard "reset pagination on filter change" patternPlanlegger.jsxloadPlan()suppressed — async data fetch; setState happens inside async callbacks, not synchronouslyTest plan
This PR touches hook execution order and setState timing in
History,MuscleMap,Report,Home,Bibliotek, andPlanlegger. The logic is unchanged — the refactors move setState calls to equivalent points in the render cycle. Verify the following golden paths on the SWA preview:🤖 Generated with Claude Code