Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Blank page after logout when the app re-renders `<Admin>` during `authProvider.logout()`

Open Beginner friendly
#11,431 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Render the app below.
  2. Open /#/posts.
  3. 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: InternalRouter in packages/ra-core/src/routing/adapters/reactRouterProvider.tsx calls createHashRouter(...) in its render body.
    Every re-render creates a new router at the current URL.
    The navigate("/login") scheduled by useLogout goes 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 RouterWrapper then 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from marmelab/react-admin

All issues in marmelab/react-admin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.