ant-design/components/pagination/useShowSizeChanger.ts

19 lines
578 B
TypeScript
Raw Normal View History

import { useMemo } from 'react';
import type { PaginationProps } from '.';
import type { SelectProps } from '../select';
export default function useShowSizeChanger(showSizeChanger?: PaginationProps['showSizeChanger']) {
return useMemo<[show: boolean | undefined, selectProps: SelectProps | undefined]>(() => {
if (typeof showSizeChanger === 'boolean') {
return [showSizeChanger, {}];
}
if (showSizeChanger && typeof showSizeChanger === 'object') {
return [true, showSizeChanger];
}
return [undefined, undefined];
}, [showSizeChanger]);
}