|
1 | 1 | import classNames from 'classnames';
|
2 |
| -import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; |
| 2 | +import useControlledState from '@rc-component/util/lib/hooks/useControlledState'; |
3 | 3 | import KeyCode from '@rc-component/util/lib/KeyCode';
|
4 | 4 | import pickAttrs from '@rc-component/util/lib/pickAttrs';
|
5 | 5 | import warning from '@rc-component/util/lib/warning';
|
@@ -75,17 +75,20 @@ const Pagination: React.FC<PaginationProps> = (props) => {
|
75 | 75 |
|
76 | 76 | const paginationRef = React.useRef<HTMLUListElement>(null);
|
77 | 77 |
|
78 |
| - const [pageSize, setPageSize] = useMergedState<number>(10, { |
79 |
| - value: pageSizeProp, |
80 |
| - defaultValue: defaultPageSize, |
81 |
| - }); |
| 78 | + const [pageSize, setPageSize] = useControlledState<number>( |
| 79 | + defaultPageSize, |
| 80 | + pageSizeProp, |
| 81 | + ); |
82 | 82 |
|
83 |
| - const [current, setCurrent] = useMergedState<number>(1, { |
84 |
| - value: currentProp, |
85 |
| - defaultValue: defaultCurrent, |
86 |
| - postState: (c) => |
87 |
| - Math.max(1, Math.min(c, calculatePage(undefined, pageSize, total))), |
88 |
| - }); |
| 83 | + const [internalCurrent, setCurrent] = useControlledState<number>( |
| 84 | + defaultCurrent, |
| 85 | + currentProp, |
| 86 | + ); |
| 87 | + |
| 88 | + const current = Math.max( |
| 89 | + 1, |
| 90 | + Math.min(internalCurrent, calculatePage(undefined, pageSize, total)), |
| 91 | + ); |
89 | 92 |
|
90 | 93 | const [internalInputVal, setInternalInputVal] = React.useState(current);
|
91 | 94 |
|
|
0 commit comments