Firebaseメモ。reactでユーザー登録するだけ。
import React from 'react';
import ReactDOM from 'react-dom';
import firebase from "firebase";
// initialize firebase app
firebase.initializeApp({
// apiKeyなど
});
// SignUp component
class SignUp extends React.Component {
constructor(props) {
super(props);
this.state = { email: '', password: '' };
this.handleSignUp = this.handleSignUp.bind(this);
}
handleSignUp() {
const { email, password } = this.state;
firebase.auth().createUserWithEmailAndPassword(email, password);
}
render() {
const { email, password } = this.state;
return (
<div>
<div>
<label htmlFor="email">Email</label>
<input id="email" value={email} type="text" onChange={ (e) => this.setState({ email: e.target.value }) } />
</div>
<div>
<label htmlFor="password">password</label>
<input id="password" value={password} type="password" onChange={ (e) => this.setState({ password: e.target.value }) } />
</div>
<button onClick={this.handleSignUp} >Sign up</button>
</div>
);
}
};
ReactDOM.render(
<SignUp />,
document.getElementById('root'),
);