File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed
in-app/v1/src/App/Tickets/New Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { useMemo } from 'react' ;
2
2
import { Link , useLocation , useNavigate } from 'react-router-dom' ;
3
3
import { useTranslation } from 'react-i18next' ;
4
- import { useMutation } from 'react-query' ;
4
+ import { useMutation , useQueryClient } from 'react-query' ;
5
5
import { Helmet } from 'react-helmet-async' ;
6
6
import { pick , cloneDeep } from 'lodash-es' ;
7
7
@@ -180,9 +180,16 @@ export function NewTicket() {
180
180
}
181
181
} , [ categories , category_id ] ) ;
182
182
183
+ const queryClient = useQueryClient ( ) ;
184
+
183
185
const { mutateAsync : submit , isLoading : submitting } = useMutation ( {
184
186
mutationFn : createTicket ,
185
187
onSuccess : ( ticketId : string ) => {
188
+ // In react-query@3, useInfiniteQuery always returns stale data
189
+ // Clear tickets query cache manaully to prevent this
190
+ const cache = queryClient . getQueryCache ( ) ;
191
+ cache . findAll ( [ 'tickets' ] ) . forEach ( ( query ) => cache . remove ( query ) ) ;
192
+
186
193
navigate ( { pathname : '' , search } , { replace : false , state : ticketId } ) ;
187
194
} ,
188
195
} ) ;
You can’t perform that action at this time.
0 commit comments