skip to Main Content

In my react-admin app when I go to some section I see the default loading page but I cannot understand the reason. It seems to appear when I go to http://localhost:3000/#/ before the redirection to http://localhost:3000/#/login and when I go to another section available also if I’m not logged in. The curious thing is that I have another public page but it’s loaded fast without showing loading page (this to say that it should not be a problem of public pages).

This is the default loading page shown (there’s a loading spinner on top but in the screenshot is at the beginning):
This is the default loading page shown

This is the Firefox Profiler, I hope it’s understandable.
Firefox profiler

What could be the problem? How can I debug it?

2

Answers


  1. I think the private routes are protected by some logic, which authenticates the user from the backend causing a loading screen before allowing him to go to that page and if he is not authenticated then that logic redirects the user to the login page and for public pages, this authenticates user logic is not needed so there is no loading screen there.

    Login or Signup to reply.
  2. As guessed by Bilal, react-admin has to fetch some information from your authProvider before it can render the Admin.

    • If you have set requireAuth to true, it will call authProvider.checkAuth()
    • If you have provided an authProvider, it will also call authProvider.getPermissions() in all cases

    This is required to display the side menu (because some resources may be visible only with the required permissions), and to declare the routes to the router.

    Feel free to look at the code to understand the full logic.

    As you can see in it, some routes are accessible even when status is still equal to 'loading': the customRoutesWithoutLayout (i.e. the routes that do not render using the default layout, and hence the side menu).

    Hence, I’d say the public routes that are available instantly in your app are probably those with noLayout.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search