File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
packages/ra-core/src/auth Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -111,9 +111,22 @@ const useLogout = (): Logout => {
111111 if ( redirectToParts [ 1 ] ) {
112112 newLocation . search = redirectToParts [ 1 ] ;
113113 }
114- navigateRef . current ( newLocation , newLocationOptions ) ;
115- resetStore ( ) ;
116- queryClient . clear ( ) ;
114+ navigateRef . current ( newLocation , {
115+ ...newLocationOptions ,
116+ flushSync : true ,
117+ } ) ;
118+
119+ // We need to reset the store after a litte delay to avoid a race condition
120+ // between the store reset and the navigation.
121+ //
122+ // This would only happen when the `authProvider.getPermissions` method returns
123+ // a resolved promise with no delay: If the store was reset before the navigation,
124+ // the `usePermissions` query would reset, causing the `CoreAdminRoutes` component to
125+ // rerender the `LogoutOnMount` component leading to an infinite loop.
126+ window . requestAnimationFrame ( ( ) => {
127+ resetStore ( ) ;
128+ queryClient . clear ( ) ;
129+ } ) ;
117130
118131 return redirectToFromProvider ;
119132 } ) ;
You can’t perform that action at this time.
0 commit comments