@@ -67,8 +67,8 @@ export const useList = <RecordType extends RaRecord = any, ErrorType = Error>(
67
67
sort : initialSort ,
68
68
filterCallback = ( record : RecordType ) => Boolean ( record ) ,
69
69
} = props ;
70
- const resourceFromContext = useResourceContext ( props ) ;
71
- const resource = props . storeKey ?? resourceFromContext ;
70
+ const resource = useResourceContext ( props ) ;
71
+
72
72
const [ fetchingState , setFetchingState ] = useState < boolean > ( isFetching ) as [
73
73
boolean ,
74
74
( isFetching : boolean ) => void ,
@@ -92,45 +92,12 @@ export const useList = <RecordType extends RaRecord = any, ErrorType = Error>(
92
92
total : data ? data . length : undefined ,
93
93
} ) ) ;
94
94
95
- // Store pagination states for each storeKey
96
- const storeKeyPaginationRef = useRef < {
97
- [ key : string ] : { page : number ; perPage : number } ;
98
- } > ( { } ) ;
99
-
100
95
// pagination logic
101
96
const { page, setPage, perPage, setPerPage } = usePaginationState ( {
102
97
page : initialPage ,
103
98
perPage : initialPerPage ,
104
99
} ) ;
105
100
106
- useEffect ( ( ) => {
107
- if ( ! resource ) return ;
108
- // Check if storeKey exists in the pagination store
109
- const currentPagination = storeKeyPaginationRef . current [ resource ] ;
110
- if ( currentPagination ) {
111
- // Restore existing pagination state for the storeKey
112
- if (
113
- page !== currentPagination . page ||
114
- perPage !== currentPagination . perPage
115
- ) {
116
- setPage ( currentPagination . page ) ;
117
- setPerPage ( currentPagination . perPage ) ;
118
- }
119
- } else {
120
- setPage ( initialPage ) ;
121
- setPerPage ( initialPerPage ) ;
122
- }
123
- storeKeyPaginationRef . current [ resource ] = { page, perPage } ;
124
- } , [
125
- resource ,
126
- setPage ,
127
- setPerPage ,
128
- initialPage ,
129
- initialPerPage ,
130
- page ,
131
- perPage ,
132
- ] ) ;
133
-
134
101
// sort logic
135
102
const { sort, setSort : setSortState } = useSortState ( initialSort ) ;
136
103
const setSort = useCallback (
@@ -328,7 +295,7 @@ export const useList = <RecordType extends RaRecord = any, ErrorType = Error>(
328
295
onUnselectItems : selectionModifiers . clearSelection ,
329
296
page,
330
297
perPage,
331
- resource : resource ,
298
+ resource : '' ,
332
299
refetch,
333
300
selectedIds,
334
301
setFilters,
@@ -354,7 +321,6 @@ export interface UseListOptions<
354
321
perPage ?: number ;
355
322
sort ?: SortPayload ;
356
323
resource ?: string ;
357
- storeKey ?: string ;
358
324
filterCallback ?: ( record : RecordType ) => boolean ;
359
325
}
360
326
0 commit comments