diff --git a/packages/react-use/src/use-paging-list/index.mdx b/packages/react-use/src/use-paging-list/index.mdx index 888e5d7..8c52b2d 100644 --- a/packages/react-use/src/use-paging-list/index.mdx +++ b/packages/react-use/src/use-paging-list/index.mdx @@ -48,7 +48,7 @@ const { // Pass a function that accepts page, pageSize pagination parameters, which needs to return a data list // Use setTotal inside this function to set the total data amount, so the paginator can display the total correctly -const { form, query, pagination, selection, list, setTotal, loading } = usePagingList( +const { form, query, pagination, selection, list, refresh, setTotal, loading } = usePagingList( async (params) => { const { page, pageSize, form } = params const { list, total } = await fetchPaginationList({ page, pageSize }) @@ -68,25 +68,28 @@ const { form, query, pagination, selection, list, setTotal, loading } = usePagin ) // useForm returns the form object, refer to useForm documentation -// form +form // useQuery returns the query object, refer to useQuery documentation -// query +query // usePagination returns the pagination object, merging state and actions, refer to usePagination documentation -// pagination +pagination // useMultiSelect returns the selection object, merging state and actions, refer to useMultiSelect documentation -// selection +selection // Data list -// list +list + +// Refresh query +refresh // Set total data amount -// setTotal +setTotal // Whether it is loading -// loading +loading ``` ## Source \{#source} @@ -104,6 +107,7 @@ const { pagination, selection, list, + refresh, setTotal, loading } = usePagingList(fetcher, options) @@ -118,7 +122,7 @@ export interface UsePagingListFetcherParams { /** * Data from the last request */ - previousData: undefined | Data + previousData: Data | undefined /** * Current page number */ @@ -147,7 +151,7 @@ export type UsePagingListFetcher = ( ```tsx export interface UsePagingListOptions { /** - * Data fetch function + * `useForm` configuration, refer to `useForm` documentation * * @defaultValue undefined */ diff --git a/packages/react-use/src/use-paging-list/index.ts b/packages/react-use/src/use-paging-list/index.ts index 355b42a..7fcf541 100644 --- a/packages/react-use/src/use-paging-list/index.ts +++ b/packages/react-use/src/use-paging-list/index.ts @@ -46,7 +46,7 @@ export interface UsePagingListFetcherParams { /** * previous data */ - previousData: undefined | Data + previousData: Data | undefined /** * current page */ diff --git a/packages/react-use/src/use-paging-list/index.zh-cn.mdx b/packages/react-use/src/use-paging-list/index.zh-cn.mdx index d77fddc..91de0f1 100644 --- a/packages/react-use/src/use-paging-list/index.zh-cn.mdx +++ b/packages/react-use/src/use-paging-list/index.zh-cn.mdx @@ -46,9 +46,9 @@ const { loading } = usePagingList(fetcher, options) -// 穿入一个接受 page, pageSize 分页参数的函数,它需要返回一个数据列表 +// 传入一个接受 page, pageSize 分页参数的函数,它需要返回一个数据列表 // 在这个函数里面使用 setTotal 来设置数据总数,以便分页器能够正确显示总数 -const { form, query, pagination, selection, list, setTotal, loading } = usePagingList( +const { form, query, pagination, selection, list, refresh, setTotal, loading } = usePagingList( async (params) => { const { page, pageSize, form } = params const { list, total } = await fetchPaginationList({ page, pageSize }) @@ -68,25 +68,28 @@ const { form, query, pagination, selection, list, setTotal, loading } = usePagin ) // useForm 返回的 form 对象,参考 useForm 文档 -// form +form // useQuery 返回的 query 对象,参考 useQuery 文档 -// query +query // usePagination 返回的 pagination 对象,合并了 state 和 actions,参考 usePagination 文档 -// pagination +pagination // useMultiSelect 返回的 selection 对象,合并了 state 和 actions,参考 useMultiSelect 文档 -// selection +selection // 数据列表 -// list +list + +// 刷新数据 +refresh // 设置数据总数 -// setTotal +setTotal // 是否正在加载 -// loading +loading ``` ## 源码 \{#source} @@ -104,6 +107,7 @@ const { pagination, selection, list, + refresh, setTotal, loading } = usePagingList(fetcher, options) @@ -118,7 +122,7 @@ export interface UsePagingListFetcherParams { /** * 上次请求的数据 */ - previousData: undefined | Data + previousData: Data | undefined /** * 当前页码 */ @@ -147,7 +151,7 @@ export type UsePagingListFetcher = ( ```tsx export interface UsePagingListOptions { /** - * 数据获取函数 + * `useForm` 的配置项,参考 useForm 文档 * * @defaultValue undefined */