LoadMore API

LoadMore extensions.

const { ...ReturnValues } = useLoadMore<R, P, FR, LR>(Service, Options);

TS Generic description

Generics not listed are consistent with the definition in the Public API chapter

LR is a generic of dataList. (Note: This generic is subject to unknown[] constraints)

See also: LoadMore

Note

The following API is a superset of Public API. If there are no special instructions, it is consistent with Public API.

Return Values

dataList

  • Type: Ref<LR>

  • Default: []

    All requests data (data taken from data[listkey]) merge array.

loadingMore

  • Type: Ref<boolean>

  • Default: false

    Is loading more, used to record whether loadMore() is triggering. If you want to determine whether Service is requesting, please use loading.

refreshing New in 1.1.0

  • Type: Ref<boolean>

  • Default: false

    Is refreshing, used to record whether refresh() is triggering.

noMore

  • Type: Ref<boolean>

  • Default: false

    Is there have more data, need use with isNoMore.

loadMore

  • Type: () => void

  • Default: 0

    Trigger load more.

reload

  • Type: () => void

    Trigger reload, used to clear all request status and request data (includes dataList), and trigger the request again.

refresh New in 1.1.0

  • Type: () => void

    Re-request data. Unlike reload(), this method will not clear dataList before the end of the request. It can be used to pull down to refresh.

queries Not Support

In LoadMore mode, Concurrent Request is not supported

mutate Not Support

In LoadMore mode, Mutation is not supported

Service

Request Method

  • Type:

    • (returnData: ReturnDataType | undefined, ...params: P) => Promise<R>
    • | (returnData: ReturnDataType | undefined, ...params: P) => string
    • | (returnData: ReturnDataType | undefined, ...params: P) => ({ url: string; [key: string]: any; })
  • Details:

    The type of the first parameter is explained as follows (when the first request is made, the first parameter is undefined)

    type ReturnDataType = {
      data: R; // The result of the last request
      dataList: LR; // The result of the current request merged array
    };
    

String Not Support

Not supported in LoadMore mode.

Object Not Support

Not supported in LoadMore mode.

Options

listKey

  • Type: string
  • Default: list
  • Details:

Gets the value at path of data. like lodash.get, so you can reference lodash documentopen in new window.

const data = { a: [{ b: { c: 3 } }] };
const listKey = 'a[0].b.c';
// => 3

Specify the path of the data attribute in listKey.

isNoMore

  • Type: (data: R) => boolean

  • Default: false

  • Details:

    Is there has more data.

queryKey Not Support

In LoadMore mode, Concurrent Request is not supported

Last Updated: 6/29/2022, 7:38:54 AM
Contributors: John