Skip to content

Commit

Permalink
docs(examples): avoid extra history entries
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Jul 18, 2022
1 parent 650ce58 commit 5e22499
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 7 additions & 4 deletions examples/infinite-scrolling/app/routes/offset/advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ export default function Index() {
return;
}
if (neededStart !== start) {
setSearchParams({
start: String(neededStart),
limit: LIMIT.toString(),
});
setSearchParams(
{
start: String(neededStart),
limit: LIMIT.toString(),
},
{ replace: true }
);
}
}, [start, neededStart, setSearchParams]);

Expand Down
13 changes: 8 additions & 5 deletions examples/infinite-scrolling/app/routes/page/advanced.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,14 @@ export default function Index() {
}
const newPage = Math.round(neededStart / limit);
if (newPage !== page) {
setSearchParams({
start: String(neededStart),
page: String(newPage),
limit: LIMIT.toString(),
});
setSearchParams(
{
start: String(neededStart),
page: String(newPage),
limit: LIMIT.toString(),
},
{ replace: true }
);
}
}, [limit, neededStart, page, setSearchParams]);

Expand Down

0 comments on commit 5e22499

Please sign in to comment.