Last active
April 10, 2017 05:39
-
-
Save LazyFatArrow/158a08c773e9b9a81f9b47047974b838 to your computer and use it in GitHub Desktop.
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 { firebaseConnect } from 'react-redux-firebase' | |
import { pathToJS, dataToJS } from 'react-redux-firebase' | |
import { connect } from 'react-redux'; | |
import AppComponent from './AppComponent'; | |
const App = ({firebase, auth}) => { | |
// logs in the user | |
const login = () => { | |
firebase.login({ | |
provider: 'google', | |
type: 'popup' | |
}); | |
} | |
// logs out the user | |
const logout = () => { | |
firebase.logout(); | |
} | |
// checks if user is logged in | |
const authed = auth && auth.uid; | |
return <AppComponent | |
authed={authed} | |
login={login.bind(this)} | |
logout={logout.bind(this)} | |
/> | |
} | |
// makes firebase available in the props | |
const wrappedApp = firebaseConnect()(App); | |
// grab the auth node from the store | |
export default connect(({firebase}) => { | |
return { | |
auth: pathToJS(firebase, 'auth') | |
} | |
}, null)(wrappedApp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment