diff --git a/taier-ui/src/hooks/index.ts b/taier-ui/src/hooks/index.ts index ab51a13803..27c3db900f 100644 --- a/taier-ui/src/hooks/index.ts +++ b/taier-ui/src/hooks/index.ts @@ -26,19 +26,13 @@ interface IPagination { export const usePagination = ({ current: initialCurrent = 1, - pageSize: initalPageSize = 20, + pageSize: initialPageSize = 20, total: initialTotal = 0, }: IPagination) => { const [current, setCurrent] = useState(initialCurrent); - const [pageSize, setPageSize] = useState(initalPageSize); + const [pageSize, setPageSize] = useState(initialPageSize); const [total, setTotal] = useState(initialTotal); - // ensure get the lastest value inside async function - const pageInfoRef = useRef({ current, pageSize, total }); - useEffect(() => { - pageInfoRef.current = { current, pageSize, total }; - }); - const setPagination = ({ current: c, pageSize: p, @@ -59,7 +53,12 @@ export const usePagination = ({ } }; - return { ...pageInfoRef.current, setPagination }; + return { + current, + pageSize, + total, + setPagination, + }; }; export function useConstant(val: T) {