Created
August 2, 2019 16:34
-
-
Save clairechabas/3741ced966cf2dd13029ea3ab4625bbd to your computer and use it in GitHub Desktop.
Main.js component connected to Redux store to listen on the auth object from Firebase reducer to redirect the user according to auth status.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { connect } from "react-redux"; | |
import Home from "./Home"; | |
import Login from "./Login"; | |
import Loader from "./Loader"; | |
const Main = ({ auth }) => { | |
return ( | |
<div> | |
{!auth.isLoaded ? <Loader /> : !auth.isEmpty ? <Home /> : <Login />} | |
</div> | |
); | |
}; | |
function mapStateToProps(state) { | |
return { | |
auth: state.firebaseReducer.auth | |
}; | |
} | |
export default connect(mapStateToProps)(Main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment