Skip to content

Commit c725ab0

Browse files
authored
fix: pass loadingState to useAsyncList's load function (#7955)
1 parent 84844d8 commit c725ab0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/@react-stately/data/src/useAsyncList.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ export function useAsyncList<T, C = string>(options: AsyncListOptions<T, C>): As
297297
sortDescriptor: action.sortDescriptor ?? data.sortDescriptor,
298298
signal: abortController.signal,
299299
cursor: action.type === 'loadingMore' ? data.cursor : undefined,
300-
filterText: previousFilterText
300+
filterText: previousFilterText,
301+
loadingState: data.state
301302
});
302303

303304
let filterText = response.filterText ?? previousFilterText;

packages/@react-stately/data/test/useAsyncList.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ describe('useAsyncList', () => {
4545
let {result} = renderHook(() => useAsyncList({load}));
4646

4747
expect(load).toHaveBeenCalledTimes(1);
48+
expect(load).toHaveBeenCalledWith({
49+
cursor: undefined,
50+
filterText: '',
51+
items: [],
52+
loadingState: 'idle',
53+
selectedKeys: new Set(),
54+
signal: expect.any(AbortSignal),
55+
sortDescriptor: undefined
56+
});
4857
let args = load.mock.calls[0][0];
4958
expect(args.items).toEqual([]);
5059
expect(args.selectedKeys).toEqual(new Set());

0 commit comments

Comments
 (0)