Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow
Last active April 10, 2017 05:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LazyFatArrow/158a08c773e9b9a81f9b47047974b838 to your computer and use it in GitHub Desktop.
Save LazyFatArrow/158a08c773e9b9a81f9b47047974b838 to your computer and use it in GitHub Desktop.
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