@@ -3,7 +3,7 @@ import get from 'lodash/get';
3
3
import isEqual from 'lodash/isEqual' ;
4
4
import { removeEmpty } from '../../util' ;
5
5
import { FilterPayload , RaRecord , SortPayload } from '../../types' ;
6
- import { useResourceContext } from '../../core' ;
6
+ import { ResourceContextValue , useResourceContext } from '../../core' ;
7
7
import usePaginationState from '../usePaginationState' ;
8
8
import useSortState from '../useSortState' ;
9
9
import { useRecordSelection } from './useRecordSelection' ;
@@ -66,8 +66,8 @@ export const useList = <RecordType extends RaRecord = any>(
66
66
sort : initialSort ,
67
67
filterCallback = ( record : RecordType ) => Boolean ( record ) ,
68
68
} = props ;
69
- const resource = useResourceContext ( props ) ;
70
-
69
+ const resourceFromContext = useResourceContext ( props ) ;
70
+ const resource = props . storeKey ?? resourceFromContext ;
71
71
const [ fetchingState , setFetchingState ] = useState < boolean > ( isFetching ) as [
72
72
boolean ,
73
73
( isFetching : boolean ) => void ,
@@ -287,7 +287,7 @@ export const useList = <RecordType extends RaRecord = any>(
287
287
onUnselectItems : selectionModifiers . clearSelection ,
288
288
page,
289
289
perPage,
290
- resource : '' ,
290
+ resource : resource ,
291
291
refetch,
292
292
selectedIds,
293
293
setFilters,
@@ -310,6 +310,7 @@ export interface UseListOptions<RecordType extends RaRecord = any> {
310
310
perPage ?: number ;
311
311
sort ?: SortPayload ;
312
312
resource ?: string ;
313
+ storeKey ?: string ;
313
314
filterCallback ?: ( record : RecordType ) => boolean ;
314
315
}
315
316
0 commit comments