Created
September 14, 2017 16:24
-
-
Save jearle/7ab9fa192aa9630cf4df6c847bcaa3a8 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, { Component } from 'react'; | |
import connect from '../../utils/connect-firebase'; | |
class CreateUser extends Component { | |
state = { | |
isCreatingUser: false, | |
error: ``, | |
} | |
submit = async (e) => { | |
e.preventDefault(); | |
this.setState({ | |
isCreatingUser: true, | |
}); | |
let error = ``; | |
try { | |
const user = await this.createUser({ | |
email: `earle.jesse@gmail.com`, | |
password: `5ohgrinD`, | |
}); | |
} catch ({ message }) { | |
error = message; | |
} | |
this.setState({ | |
isCreatingUser: false, | |
error, | |
}); | |
} | |
render () { | |
const { | |
isCreatingUser, | |
error, | |
} = this.state; | |
return ( | |
<form onSubmit={this.submit}> | |
<label> | |
<input placeholder={`email`} /> | |
</label> | |
<label> | |
<input placeholder={`password`} /> | |
</label> | |
<label> | |
<input placeholder={`confirm password`} /> | |
</label> | |
<label> | |
<input placeholder={`first name`} /> | |
</label> | |
<label> | |
<input placeholder={`last name`} /> | |
</label> | |
<button disabled={isCreatingUser} type={`submit`}> | |
create user | |
</button> | |
<p> | |
{error} | |
</p> | |
</form> | |
); | |
} | |
} | |
export default connect(CreateUser); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment