Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from "react";
  2. import { Link } from "react-router-dom";
  3. class Register extends Component {
  4.   constructor() {
  5.     super();
  6.     this.state = {
  7.       name: "",
  8.       email: "",
  9.       password: "",
  10.       password2: "",
  11.       errors: {}
  12.     };
  13.   }
  14. onChange = e => {
  15.     this.setState({ [e.target.id]: e.target.value });
  16.   };
  17. onSubmit = e => {
  18.     e.preventDefault();
  19. const newUser = {
  20.       name: this.state.name,
  21.       email: this.state.email,
  22.       password: this.state.password,
  23.       password2: this.state.password2
  24.     };
  25. console.log(newUser);
  26.   };
  27. render() {
  28.     const { errors } = this.state;
  29. return (
  30.       <div className="container">
  31.         <div className="row">
  32.           <div className="col s8 offset-s2">
  33.             <Link to="/" className="btn-flat waves-effect">
  34.               <i className="material-icons left">keyboard_backspace</i> Back to
  35.               home
  36.             </Link>
  37.             <div className="col s12" style={{ paddingLeft: "11.250px" }}>
  38.               <h4>
  39.                 <b>Register</b> below
  40.               </h4>
  41.               <p className="grey-text text-darken-1">
  42.                 Already have an account? <Link to="/login">Log in</Link>
  43.               </p>
  44.             </div>
  45.             <form noValidate onSubmit={this.onSubmit}>
  46.               <div className="input-field col s12">
  47.                 <input
  48.                   onChange={this.onChange}
  49.                   value={this.state.name}
  50.                   error={errors.name}
  51.                   id="name"
  52.                   type="text"
  53.                 />
  54.                 <label htmlFor="name">Name</label>
  55.               </div>
  56.               <div className="input-field col s12">
  57.                 <input
  58.                   onChange={this.onChange}
  59.                   value={this.state.email}
  60.                   error={errors.email}
  61.                   id="email"
  62.                   type="email"
  63.                 />
  64.                 <label htmlFor="email">Email</label>
  65.               </div>
  66.               <div className="input-field col s12">
  67.                 <input
  68.                   onChange={this.onChange}
  69.                   value={this.state.password}
  70.                   error={errors.password}
  71.                   id="password"
  72.                   type="password"
  73.                 />
  74.                 <label htmlFor="password">Password</label>
  75.               </div>
  76.               <div className="input-field col s12">
  77.                 <input
  78.                   onChange={this.onChange}
  79.                   value={this.state.password2}
  80.                   error={errors.password2}
  81.                   id="password2"
  82.                   type="password"
  83.                 />
  84.                 <label htmlFor="password2">Confirm Password</label>
  85.               </div>
  86.               <div className="col s12" style={{ paddingLeft: "11.250px" }}>
  87.                 <button
  88.                   style={{
  89.                     width: "150px",
  90.                     borderRadius: "3px",
  91.                     letterSpacing: "1.5px",
  92.                     marginTop: "1rem"
  93.                   }}
  94.                   type="submit"
  95.                   className="btn btn-large waves-effect waves-light hoverable blue accent-3"
  96.                 >
  97.                   Sign up
  98.                 </button>
  99.               </div>
  100.             </form>
  101.           </div>
  102.         </div>
  103.       </div>
  104.     );
  105.   }
  106. }
  107. export default Register;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement