From 9660529daa51ef04f76a414faa45299e68414e90 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Sat, 28 Feb 2026 22:15:27 +0000 Subject: [PATCH] Fix error that prevents the page from loading correctly Correctly structures `useMemo` hooks before conditional returns in `client/src/pages/home.tsx` to comply with React's Rules of Hooks, resolving a runtime error. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 517dfa7b-26ac-463d-a6e1-a58c6df97188 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: eab45d08-d53d-4195-b17a-e67bd104fcbc Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/f209e72a-0939-48fa-84fc-57854de71967/517dfa7b-26ac-463d-a6e1-a58c6df97188/0ZGabQy Replit-Helium-Checkpoint-Created: true --- client/src/pages/home.tsx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/client/src/pages/home.tsx b/client/src/pages/home.tsx index 89ab1e8..cb94372 100644 --- a/client/src/pages/home.tsx +++ b/client/src/pages/home.tsx @@ -404,17 +404,8 @@ export default function Home() { const focalPoints = useFocalPoints(); - if (isLoading || !articles) { - return ( -
-
-
-
- ); - } - const shuffled = useMemo(() => { + if (!articles) return []; const arr = [...articles]; for (let i = arr.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); @@ -459,9 +450,22 @@ export default function Home() { return items; }, [shuffled, widgets]); - const gridRows: (typeof gridItems)[] = []; - for (let i = 0; i < gridItems.length; i += 4) { - gridRows.push(gridItems.slice(i, i + 4)); + const gridRows: (typeof gridItems)[] = useMemo(() => { + const rows: (typeof gridItems)[] = []; + for (let i = 0; i < gridItems.length; i += 4) { + rows.push(gridItems.slice(i, i + 4)); + } + return rows; + }, [gridItems]); + + if (isLoading || !articles) { + return ( +
+
+
+
+ ); } return (