Fix: move useState(showChecklist) before conditional returns

React hooks must be called unconditionally on every render. The
checklist useState was at line 89, after 'if (loading) return' at
line 70 — hooks violation crashed the entire React app (blank screen).
Moved to line 38 with the other state declarations.
This commit is contained in:
Claude 2026-07-13 23:21:16 +00:00
parent befcc3346a
commit e1b213a54e

View file

@ -35,6 +35,7 @@ export default function Dashboard() {
const [aiStatus, setAiStatus] = useState(null) const [aiStatus, setAiStatus] = useState(null)
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
const [syncing, setSyncing] = useState(null) const [syncing, setSyncing] = useState(null)
const [showChecklist, setShowChecklist] = useState(() => localStorage.getItem("diligence_setup_dismissed") !== "true")
const navigate = useNavigate() const navigate = useNavigate()
useEffect(() => { loadAll() }, []) useEffect(() => { loadAll() }, [])
@ -85,11 +86,6 @@ export default function Dashboard() {
{ key: 'daily_checkin', label: 'Check-in', icon: '✅', pts: 10, color: '#00BCD4', tip: 'Just show up and check in. The easiest points — consistency matters more than intensity.' }, { key: 'daily_checkin', label: 'Check-in', icon: '✅', pts: 10, color: '#00BCD4', tip: 'Just show up and check in. The easiest points — consistency matters more than intensity.' },
] ]
// Getting-started checklist shows until dismissed
const [showChecklist, setShowChecklist] = useState(() => {
return localStorage.getItem('diligence_setup_dismissed') !== 'true'
})
const setupItems = [ const setupItems = [
{ done: true, label: 'Create account', link: null }, { done: true, label: 'Create account', link: null },
{ done: !!status.program_name, label: 'Join a program', link: '/programs' }, { done: !!status.program_name, label: 'Join a program', link: '/programs' },