Skip to content

Commit

Permalink
fix(table): fix table error (#1623)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Dec 6, 2021
1 parent 6cf8f7d commit 860e1a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ const Pagination = WithRef<HTMLDivElement, PaginationProps>((props, ref) => {
nav: textObject.ariaLabelNav,
}[type]);

if (hideOnSinglePage && maxPages <= 1) return null;

const paginationProviderValue = useMemo<PaginationContextType>(
() => ({
onPageSizeChange,
Expand All @@ -104,6 +102,8 @@ const Pagination = WithRef<HTMLDivElement, PaginationProps>((props, ref) => {
]
);

if (hideOnSinglePage && maxPages <= 1) return null;

return (
<div ref={ref} data-testid="pagination" className={classNames([className, prefixCls])} {...otherProps}>
<PaginationContext.Provider value={paginationProviderValue}>
Expand Down
4 changes: 3 additions & 1 deletion src/table/hook/usePagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ const usePagination = <RecordType,>(
if (controlledCurrent * controlledPageSize > totalMemo) {
onChange?.(Math.ceil(totalMemo / controlledPageSize) || 1, controlledPageSize);
}
}, [controlledCurrent, controlledPageSize, onChange, totalMemo]);
// 不应该检测 onChange 依赖
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [controlledCurrent, controlledPageSize, totalMemo]);

const paginationData = useMemo(() => {
if (pagination === false || !controlledPageSize) {
Expand Down

1 comment on commit 860e1a3

@vercel
Copy link

@vercel vercel bot commented on 860e1a3 Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.