Skip to content

Commit 045e402

Browse files
committed
fetch next image when page first loaded
1 parent 3c633f7 commit 045e402

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/app/about/interact.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ const Interact = () => {
119119
const saved = localStorage.getItem('ABOUT_currentPage');
120120
if (saved) {
121121
setCurrentPage(parseInt(saved));
122+
const next_page = (parseInt(saved) + 1) % pages.length;
123+
setNextPage(next_page);
122124
} else {
123125
setCurrentPage(1);
126+
setNextPage(2);
124127
}
125128
}, []);
126129

@@ -142,6 +145,7 @@ const Interact = () => {
142145

143146
// Use a consistent page during server rendering
144147
const page = pages[currentPage];
148+
const n_page = pages[nextPage];
145149

146150
return (
147151
<div className="flex flex-col gap-4">
@@ -156,7 +160,7 @@ const Interact = () => {
156160
priority
157161
/>
158162
{/* preload next image... i wish there was a better way to do this*/}
159-
<link rel="preload" href={pages[nextPage].image} as="image"></link>
163+
<link rel="preload" href={n_page.image} as="image"></link>
160164
</div>
161165

162166
<div className="w-full border-2 border-gray-800 rounded p-2">

0 commit comments

Comments
 (0)