Skip to content

Commit

Permalink
return gfay
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Dec 10, 2024
1 parent 780d2ca commit b655c92
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 3 additions & 6 deletions components/bal/voies-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ function VoiesList({
const [isDisabled, setIsDisabled] = useState(false);
const [showUncertify, setShowUncertify] = useState(false);
const router = useRouter();
const [page, setPage] = useState<number>(
Number(router.query?.page as string) || 1
);

let page = Number(router.query?.page as string) || 1;
const search: string = router.query?.search as string;

const [filtered, setFilter] = useFuse(
Expand Down Expand Up @@ -108,9 +105,9 @@ function VoiesList({
(change: number) => {
router.query[QUERY_PAGE] = String(change);
router.push(router, undefined, { shallow: true });
setPage(change);
page = change;

Check warning on line 108 in components/bal/voies-list.tsx

View workflow job for this annotation

GitHub Actions / build (22.x)

Assignments to the 'page' variable from inside React Hook useCallback will be lost after each render. To preserve the value over time, store it in a useRef Hook and keep the mutable value in the '.current' property. Otherwise, you can move this variable directly inside useCallback
},
[setPage, router]
[, router]
);

const changeFilter = useCallback(
Expand Down
2 changes: 2 additions & 0 deletions components/pagination-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ function PaginationList({
page={page}
totalPages={Math.ceil(items?.length / LIMIT)}
onPageChange={(newPage) => setPage(newPage)}
onPreviousPage={() => setPage(page - 1)}
onNextPage={() => setPage(page + 1)}
></Pagination>
)}
</Pane>
Expand Down

0 comments on commit b655c92

Please sign in to comment.