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
This commit is contained in:
sebastjanartic 2026-02-28 22:15:27 +00:00
parent 59986d4fc3
commit 9660529daa

View File

@ -404,17 +404,8 @@ export default function Home() {
const focalPoints = useFocalPoints();
if (isLoading || !articles) {
return (
<div className="min-h-screen bg-background">
<Header />
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4"><BentoSkeleton /></main>
<Footer />
</div>
);
}
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 (
<div className="min-h-screen bg-background">
<Header />
<main className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4"><BentoSkeleton /></main>
<Footer />
</div>
);
}
return (