Guest User

Untitled

a guest
Aug 22nd, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import React from 'react';
  2. //import PropTypes from prop-types define your props .
  3. import PropTypes from 'prop-types';
  4. //import css file for styling
  5. import './Form.css';
  6.  
  7. const Form = (props) => {
  8. return (
  9. <div className="register-form">
  10. <h2>Register Form</h2>
  11. <label>Username</label>
  12. <input type="text" value={props.username} onChange={e => props.handleUsername(e.target.value)} />
  13. <label>Email</label>
  14. <input type="text" value={props.email} onChange={e => props.handleEmail(e.target.value)} />
  15. <label>Password</label>
  16. <input type="text" value={props.password} onChange={e => props.handlePassword(e.target.value)} />
  17. <button onClick={() => props.register()}>Register</button>
  18. </div>
  19. );
  20. };
  21.  
  22. //Define your proptypes.
  23. Form.propTypes = {
  24. username: PropTypes.string.isRequired,
  25. email: PropTypes.string.isRequired,
  26. password: PropTypes.string.isRequired,
  27. handleUsername: PropTypes.func.isRequired,
  28. handleEmail: PropTypes.func.isRequired,
  29. handlePassword: PropTypes.func.isRequired,
  30. register: PropTypes.func.isRequired
  31. }
  32. export default Form;
Add Comment
Please, Sign In to add comment