From 75361d6f0ae37d60ca2d564a695b212a3be6b03b Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Fri, 24 Apr 2020 12:01:34 +0200 Subject: [PATCH] pages don't render if condition not met --- client/src/pages/Account/index.jsx | 3 +++ client/src/routes/PrivateRoute.jsx | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/pages/Account/index.jsx b/client/src/pages/Account/index.jsx index 0677297..3504806 100644 --- a/client/src/pages/Account/index.jsx +++ b/client/src/pages/Account/index.jsx @@ -2,6 +2,7 @@ import React from "react"; import { Container } from "reactstrap"; import PasswordChangeForm from "../../components/PasswordChangeForm"; import PasswordForgetForm from "../../components/PasswordForgetForm"; +import { useFirebase } from "../../services/auth"; const styles = { root: { @@ -11,6 +12,8 @@ const styles = { }; const AccountPage = () => { + const auth = useFirebase(); + return (

Account

diff --git a/client/src/routes/PrivateRoute.jsx b/client/src/routes/PrivateRoute.jsx index afeca3a..2b278c8 100644 --- a/client/src/routes/PrivateRoute.jsx +++ b/client/src/routes/PrivateRoute.jsx @@ -11,18 +11,19 @@ const PrivateRoute = ({ ...rest }) => { const firebase = useFirebase(); - let render; + let render = null; useEffect(() => { firebase.auth.onAuthStateChanged((authUser) => { if (!condition(authUser)) { history.push(ROUTES.SIGN_IN); } else { - render = condition(authUser) - ? (props) => - : null; + // render = condition(authUser) + // ? (props) => + // : null; } }); }, [firebase.auth, condition, history]); + render = (props) => ; return ; };