I did Authentication with fireBase and a PrivateRoute for the login users. But when I get in one of each other component (not Product login or signup) the URL update but it does not show up. App.js
function App() {
return (
<AuthProvider>
<Switch>
<PrivateRoute exact path='/' component={MainPageComp}/>
<Route path='/Signup' component={SignupComp}/>
<Route path='/Login' component={LoginComp}/>
</Switch>
</AuthProvider>
);
}
In the MainPageComponent there are also Routes:
<Switch>
<PrivateRoute exact path='/' component={ProductsComp}/>
<Route path='/Products' component={ProductsComp}/>
<Route path='/Customers' component={CustomersComp}/>
<Route path='/Purchases' component={PurchasesComp}/>
<Route path='/AddProduct' component={AddProductComp}/>
<Route path='/EditProduct/:id' component={EditProductComp}/>
<Route path='/EditCustomer/:id' component={EditCustomerComp}/>
</Switch>
PrivateRoute.js:
export default function PrivateRoute({component:Component,...rest}){
const {currentUser} = useAuth()
return(
<Route
{...rest}
render={props=>{
return currentUser?<Component {...props}/>:<Redirect to='/login'/>
}}>
</Route>
)
}
Thanks for the helpers