@@ -3,16 +3,11 @@ import { useParams } from 'react-router-dom';
33
44import { useAuthenticated , useRequireAccess } from '../../auth' ;
55import { RaRecord , MutationMode , TransformData } from '../../types' ;
6- import {
7- useRedirect ,
8- RedirectionSideEffect ,
9- useCreatePath ,
10- } from '../../routing' ;
6+ import { useRedirect , RedirectionSideEffect } from '../../routing' ;
117import { useNotify } from '../../notification' ;
128import {
139 useGetOne ,
1410 useUpdate ,
15- useRefresh ,
1611 UseGetOneHookValue ,
1712 HttpError ,
1813 UseGetOneOptions ,
@@ -86,9 +81,7 @@ export const useEditController = <
8681 const getRecordRepresentation = useGetRecordRepresentation ( resource ) ;
8782 const translate = useTranslate ( ) ;
8883 const notify = useNotify ( ) ;
89- const createPath = useCreatePath ( ) ;
9084 const redirect = useRedirect ( ) ;
91- const refresh = useRefresh ( ) ;
9285 const { id : routeId } = useParams < 'id' > ( ) ;
9386 if ( ! routeId && ! propsId ) {
9487 throw new Error (
@@ -126,16 +119,7 @@ export const useEditController = <
126119 notify ( 'ra.notification.item_doesnt_exist' , {
127120 type : 'error' ,
128121 } ) ;
129- // We need to flushSync to ensure the redirect happens before the refresh
130- // Otherwise this can cause an infinite loop when the record is not found
131- redirect ( ( ) => ( {
132- pathname : createPath ( {
133- resource,
134- type : 'list' ,
135- } ) ,
136- flushSync : true ,
137- } ) ) ;
138- refresh ( ) ;
122+ redirect ( 'list' , resource ) ;
139123 } ,
140124 refetchOnReconnect : false ,
141125 refetchOnWindowFocus : false ,
0 commit comments