Blank page after logout when the app re-renders `<Admin>` during `authProvider.logout()`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- react, typescript
- Domain
- frontend
Research direction
Start with InternalRouter in packages/ra-core/src/routing/adapters/reactRouterProvider.tsx, where createHashRouter is called during rendering. Trace how the router instance is used when useLogout navigates to /login and the component re-renders. Done means the login page renders after the described reproduction, including when the component above <Admin> re-renders during logout.
Written by the indexing model from the issue text.
Description
What you were expecting:
When checkAuth fails, the user lands on the login page.
What happened instead:
The URL changes to #/login, but the page stays blank.
The router is still on the previous location, rendering LogoutOnMount (which renders null).
It happens whenever the component rendering <Admin> re-renders while authProvider.logout() is running.
Auth SDKs commonly trigger this: clearing the session notifies a context provider above <Admin>.
Steps to reproduce:
- Render the app below.
- Open
/#/posts. - The URL becomes
/#/login, but nothing is rendered.
Related code:
import { useState } from "react";
import { Admin, CustomRoutes } from "react-admin";
import { Route } from "react-router-dom";
let rerender = () => {};
const authProvider = {
login: () => Promise.resolve(),
checkAuth: () => Promise.reject(new Error("no session")),
checkError: () => Promise.resolve(),
getPermissions: () => Promise.resolve(),
logout: () => {
rerender(); // stands for an auth SDK notifying the app that the session was cleared
return Promise.resolve();
},
};
export const App = () => {
const [, setTick] = useState(0);
rerender = () => setTick((t) => t + 1);
return (
<Admin authProvider={authProvider} requireAuth loginPage={() => <div>Login page</div>}>
<CustomRoutes>
<Route path="/posts" element={<div>Posts</div>} />
</CustomRoutes>
</Admin>
);
};
Other information:
-
Cause:
InternalRouterinpackages/ra-core/src/routing/adapters/reactRouterProvider.tsxcallscreateHashRouter(...)in its render body.
Every re-render creates a new router at the current URL.
Thenavigate("/login")scheduled byuseLogoutgoes to the discarded router: it updates the URL, but the current router never sees it. -
Suggested fix: create the router once, e.g. with
useState(() => createHashRouter(...)). -
Workaround: wrap the app in a router created once, which
RouterWrapperthen uses:const router = createHashRouter([{ path: "*", element: <App /> }]); root.render(<RouterProvider router={router} />);
Environment
- React-admin version: 5.15.5
- React version: 19.3.1
- React Router version: 7.18.4
- Dominant language
- TypeScript
- Stars
- 27k
- Forks
- 5.5k
- Avg merge
- 1d 3m
- Merged PRs (30d)
- 32
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from marmelab/react-admin
-
Pagination: page button aria-labels are not translated on small screensPossibly taken @Singmin claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
marmelab/react-admin#11427 ·
Maintainers usually reply within 1 day
-
Add emptyText property to SelectArrayInputPossibly taken @kwitykwity claimed this 59 days ago. Openenhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
marmelab/react-admin#10454 · 7 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 Over a week Newbie friendliness 38/100
marmelab/react-admin#11426 · 1 reaction ·
Maintainers usually reply within 1 day
-
ra-data-graphql-simple: outdated graphql-ast-types-browser dependency causes npm peer warningsMay be free again @bipul724 claimed this 12 days ago, and no pull request is open. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
marmelab/react-admin#11395 · 1 comment ·
Maintainers usually reply within 1 day
-
Fix decode-uri-component DoS (CVE-2026-45822) by dropping query-stringMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
marmelab/react-admin#11380 · 1 comment ·
Maintainers usually reply within 1 day
All issues in marmelab/react-admin
Similar issues
-
Parallel reticle_verify opens per-flow leases without the source lease's ignoreHTTPSErrorsPossibly taken @as992949791 claimed this today. Opengood first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
reticlehq/reticle#2033 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:quality p3-medium ready-for-agent type:docs
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
fderuiter/deruiter.dev#3589 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
manfredsteyer/angular-oauth2-oidc#1514 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
db-ux-design-system/core-web#8655 ·
Maintainers usually reply within 1 day