score:0

function App() {
  const dispatch = useDispatch();
  const user = useSelector(selectUser);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    auth.onAuthStateChanged((authUser) => {
      if (authUser) {
        // the user is logged in
        console.log('user is ', authUser);
        dispatch(
          login({
            uid: authUser.uid,
            email: authUser.email,
          })
        );
      } else {
        //the user is logged out
        dispatch(logout());
      }
      setLoading(false);
    });
  }, [dispatch]);
  return (
    <div className="App">
      {!loading && (
        <Switch>
          <PrivateRoute exact path="/" user={user} component={Home} />
          <PrivateRoute

Related Query

More Query from same tag