Skip to content

Commit 2c4c17a

Browse files
committed
fix: incremental loading
1 parent 3411bc2 commit 2c4c17a

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/app/blog/page.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,18 +143,18 @@ export default function Blog() {
143143
const loadAllGists = async () => {
144144
try {
145145
let currentPage = 1;
146-
let allGists: Gist[] = [];
147146
let hasMore = true;
148-
147+
149148
while (hasMore) {
150149
const { gists: pageGists, hasMore: hasMoreGists } = await fetchGists(currentPage);
151-
152-
allGists = [...allGists, ...pageGists];
150+
151+
// Atualiza os gists incrementalmente
152+
setGists(prev => [...prev, ...pageGists]);
153+
153154
hasMore = hasMoreGists;
154155
currentPage++;
155156
}
156-
157-
setGists(allGists);
157+
158158
setLoading(false);
159159
} catch (err) {
160160
setError(err instanceof Error ? err.message : 'Erro ao carregar os gists');

0 commit comments

Comments
 (0)