Last active
May 14, 2019 17:26
-
-
Save samcorcos/7fb3b995c682e3c50ba6d7a6046e0d89 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { Context } from '../lib/context' | |
import { firebase } from '../lib/firebase' | |
export default class Home extends React.Component { | |
constructor (props) { | |
super(props) | |
this.state = { | |
email: '', | |
password: '' | |
} | |
} | |
render () { | |
return ( | |
<Context.Consumer> | |
{store => { | |
console.log(store) | |
if (!store.currentUser.uid) { | |
return ( | |
<div> | |
<input placeholder='Email' onChange={e => this.setState({ email: e.target.value })} value={this.state.email} /> | |
<input type='password' placeholder='Password' onChange={e => this.setState({ password: e.target.value })} value={this.state.password} /> | |
<button onClick={() => firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)}>Submit</button> | |
</div> | |
) | |
} | |
return ( | |
<div> | |
<div>Email: {store.currentUser.email}</div> | |
<button onClick={() => store.signOut()}>Sign out</button> | |
</div> | |
) | |
}} | |
</Context.Consumer> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment