Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class Login extends Component {
  4.  
  5. constructor() {
  6. super();
  7. this.state = {
  8. email: '',
  9. password: '',
  10. errors: {}
  11. }
  12. this.handleInputChange = this.handleInputChange.bind(this);
  13. this.handleSubmit = this.handleSubmit.bind(this);
  14. }
  15.  
  16. handleInputChange(e) {
  17. this.setState({
  18. [e.target.name]: e.target.value
  19. })
  20. }
  21.  
  22. handleSubmit(e) {
  23. e.preventDefault();
  24. const user = {
  25. email: this.state.email,
  26. password: this.state.password,
  27. }
  28. console.log(user);
  29. }
  30.  
  31. render() {
  32. return(
  33. <div className="container" style={{ marginTop: '50px', width: '700px'}}>
  34. <h2 style={{marginBottom: '40px'}}>Login</h2>
  35. <form onSubmit={ this.handleSubmit }>
  36. <div className="form-group">
  37. <input
  38. type="email"
  39. placeholder="Email"
  40. className="form-control"
  41. name="email"
  42. onChange={ this.handleInputChange }
  43. value={ this.state.email }
  44. />
  45. </div>
  46. <div className="form-group">
  47. <input
  48. type="password"
  49. placeholder="Password"
  50. className="form-control"
  51. name="password"
  52. onChange={ this.handleInputChange }
  53. value={ this.state.password }
  54. />
  55. </div>
  56. <div className="form-group">
  57. <button type="submit" className="btn btn-primary">
  58. Login User
  59. </button>
  60. </div>
  61. </form>
  62. </div>
  63. )
  64. }
  65. }
  66.  
  67. export default Login;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement