What is the bug?
React requires every hook (useState, useEffect, useMemo, etc.)
to be called unconditionally on every render — in the same order, every time.
Five page components currently call hooks after an early
if (!model) return null guard. When model is null the component
exits early and those hooks are skipped. When model gets a value
those hooks suddenly run. React detects the mismatch and throws:
Rendered more hooks than during the previous render.
In development this surfaces as a crash. In production it causes
unpredictable behavior.
## Affected files (confirmed on current main)
| File |
Early return line |
Hooks called after it |
src/pages/OverviewPage.jsx |
Line 14 |
useState, useRef, useEffect |
src/pages/RepositoriesPage.jsx |
Line 40 |
useMemo ×2, useSortedData |
src/pages/ContributorsPage.jsx |
Line 46 |
useNavigate, useMemo ×2, useSortedData |
src/pages/GovernancePage.jsx |
Line 17 |
useMemo |
src/pages/AnalyticsPage.jsx |
Line 27 |
useMemo ×3 |
## Steps to Reproduce
- Load the app with a valid org
- Navigate to any affected page
- Clear the org so
model becomes null, then reload data
- Browser console throws:
Warning: React has detected a change in the order of Hooks
## Proposed Fix
Move all hook calls above the guard. Use optional chaining so hooks
work safely when model is null:
export default function ExamplePage() {
// All hooks first, unconditionally
const { model } = useApp()
const allRepos = model?.allRepos ?? []
const langs = useMemo(() => [...new Set(allRepos.map(r => r.language))], [allRepos])
// Guard comes after all hooks
if (!model) return null
}
What is the bug?
React requires every hook (
useState,useEffect,useMemo, etc.)to be called unconditionally on every render — in the same order, every time.
Five page components currently call hooks after an early
if (!model) return nullguard. Whenmodelis null the componentexits early and those hooks are skipped. When
modelgets a valuethose hooks suddenly run. React detects the mismatch and throws:
In development this surfaces as a crash. In production it causes
unpredictable behavior.
## Affected files (confirmed on current
main)src/pages/OverviewPage.jsxuseState,useRef,useEffectsrc/pages/RepositoriesPage.jsxuseMemo×2,useSortedDatasrc/pages/ContributorsPage.jsxuseNavigate,useMemo×2,useSortedDatasrc/pages/GovernancePage.jsxuseMemosrc/pages/AnalyticsPage.jsxuseMemo×3## Steps to Reproduce
modelbecomes null, then reload dataWarning: React has detected a change in the order of Hooks## Proposed Fix
Move all hook calls above the guard. Use optional chaining so hooks
work safely when
modelis null: