File tree Expand file tree Collapse file tree 1 file changed +11
-15
lines changed
packages/ra-core/src/dataProvider Expand file tree Collapse file tree 1 file changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -158,21 +158,6 @@ export const useCreate = <
158158 { updatedAt }
159159 ) ;
160160
161- if ( mutationMode === 'pessimistic' ) {
162- queryClient . invalidateQueries ( {
163- queryKey : [ resource , 'getList' ] ,
164- } ) ;
165- queryClient . invalidateQueries ( {
166- queryKey : [ resource , 'getInfiniteList' ] ,
167- } ) ;
168- queryClient . invalidateQueries ( {
169- queryKey : [ resource , 'getMany' ] ,
170- } ) ;
171- queryClient . invalidateQueries ( {
172- queryKey : [ resource , 'getManyReference' ] ,
173- } ) ;
174- }
175-
176161 return clonedData ;
177162 } ,
178163 getSnapshot : ( { resource, ...params } , { mutationMode } ) => {
@@ -234,6 +219,17 @@ export const useCreate = <
234219 exact : true ,
235220 } ) ;
236221 } ,
222+ onSettled : (
223+ result ,
224+ error ,
225+ variables ,
226+ context : { snapshot : Snapshot }
227+ ) => {
228+ // For deletion, we always refetch after error or success:
229+ context . snapshot . forEach ( ( [ queryKey ] ) => {
230+ queryClient . invalidateQueries ( { queryKey } ) ;
231+ } ) ;
232+ } ,
237233 }
238234 ) ;
239235
You can’t perform that action at this time.
0 commit comments