Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.

Commit

Permalink
fix: fix eslint warning
Browse files Browse the repository at this point in the history
  • Loading branch information
makotot committed Mar 4, 2021
1 parent 1736540 commit 9b1a662
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
extends: [
'react-app',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
settings: {
react: {
version: 'detect',
},
},
};
6 changes: 3 additions & 3 deletions example/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const App: React.FC<{
</div>
<Grid>
{props.hasPrev() && (
<a href="#" data-testid="hasPrev">
<a href="#prev" data-testid="hasPrev">
prev
</a>
)}
Expand Down Expand Up @@ -55,7 +55,7 @@ export const App: React.FC<{
{page}
</span>
) : (
<a href="#" key={page} data-testid="pageItems">
<a href="#page" key={page} data-testid="pageItems">
{page}
</a>
);
Expand All @@ -72,7 +72,7 @@ export const App: React.FC<{
);
})}
{props.hasNext() && (
<a href="#" data-testid="hasNext">
<a href="#next" data-testid="hasNext">
next
</a>
)}
Expand Down
25 changes: 22 additions & 3 deletions src/usePaginated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ export const usePaginated: UsePaginated = ({
currentPage + siblingsSize
)
);
}, [currentPage, siblingsSize, displayPageItemsSize]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [
isReachedToFirst,
isReachedToLast,
currentPage,
siblingsSize,
displayPageItemsSize,
]);

const hasPrev = useCallback(() => currentPage > 1, [currentPage]);
const hasNext = useCallback(() => totalPage > currentPage, [
Expand All @@ -61,7 +68,13 @@ export const usePaginated: UsePaginated = ({
.filter(p => !pages.includes(p));

return boundary;
}, [pages]);
}, [
boundarySize,
isReachedToFirst,
pages,
prevAllPages.length,
totalPageItems,
]);

const getLastBoundary = useCallback(() => {
if (isReachedToLast()) {
Expand All @@ -74,7 +87,13 @@ export const usePaginated: UsePaginated = ({
.slice(totalPageItems.length - boundarySize, totalPageItems.length)
.filter(p => !pages.includes(p));
return boundary;
}, [pages]);
}, [
boundarySize,
isReachedToLast,
nextAllPages.length,
pages,
totalPageItems,
]);

const isPrevTruncated =
prevAllPages.filter(
Expand Down

0 comments on commit 9b1a662

Please sign in to comment.