diff --git a/src/app/page.tsx b/src/app/page.tsx index 188115d..2f9fc47 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -65,7 +65,22 @@ const TabLoadingFallback = () =>
// ============================================================================ function GrimoireTab() { - const grimoireSpells = Object.values(SPELLS_DEF).filter((s: any) => s.grimoire); + // Handle SSR - dont access SPELLS_DEF during server-side rendering + // Use state and useEffect to only access on client-side + const [grimoireSpells, setGrimoireSpells] = useState([]); + + useEffect(() => { + // Only access SPELLS_DEF on client-side + if (typeof window !== 'undefined' && SPELLS_DEF) { + const filtered = Object.values(SPELLS_DEF).filter((s: any) => s.grimoire); + setGrimoireSpells(filtered); + } + }, []); + + if (!grimoireSpells.length) { + return
Loading grimoire...
; + } + const availablePages = Math.ceil(grimoireSpells.length / 12); return ( @@ -131,7 +146,7 @@ export default function ManaLoopGame() { const gameOver = useUIStore((s) => s.gameOver); - // Computed effects from upgrades and equipment + // Derived state const upgradeEffects = getUnifiedEffects({ skillUpgrades, skillTiers, @@ -139,7 +154,6 @@ export default function ManaLoopGame() { equipmentInstances: {} }); - // Derived stats const maxMana = computeMaxMana({ skills, prestigeUpgrades, @@ -192,14 +206,14 @@ export default function ManaLoopGame() { }, [gameLoop]); // Conditional returns AFTER all hooks - if (typeof window === 'undefined') { - return
Loading...
; - } - if (gameOver) { return ; } + if (typeof window === 'undefined') { + return
Loading...
; + } + return ( @@ -216,10 +230,10 @@ export default function ManaLoopGame() { {/* Main Content */}
-
@@ -242,7 +256,7 @@ export default function ManaLoopGame() { }> - + @@ -260,7 +274,7 @@ export default function ManaLoopGame() { }> - +