prescottprue / react-redux-firebase

Redux bindings for Firebase. Includes React Hooks and Higher Order Components.
https://react-redux-firebase.com
MIT License
2.55k stars 559 forks source link

AuthIsLoaded is unreliable #1074

Closed d4nielhdz closed 3 years ago

d4nielhdz commented 3 years ago

What is the current behavior?

Wrapping my <Router /> component with <AuthIsLoaded /> makes the app load indefinitely. Apparently, the auth isn't loaded and it just stays loading.

What is the expected behavior?

It should just take a while to load the auth and then the app should work as normal

Steps to reproduce

I've had a hard time reproducing this issue. I started having it in recent projects. Just creating a new React project and adding a few dependencies seems to trigger it. Sometimes it disappears out of the blue.

Which versions of dependencies, and which browser and OS are affected by this issue? Did this work in previous versions or setups?

Here are the versions of dependencies that might be useful to know:

    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-redux": "^7.2.2",
    "react-redux-firebase": "^3.8.0",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "4.0.3",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",

I apologize for the vagueness of the description. I might try to reproduce the issue in a sandbox.

d4nielhdz commented 3 years ago

I found out the reason was sometimes Firebase doesn't initialize before the auth state is checked. Moving the Firebase initialization so it's always initialized before checking the auth state solved the issue.