add proptypes to login form

This commit is contained in:
catarak 2016-06-27 14:00:45 -04:00
parent 7a07d5380d
commit 29013b99f1

View file

@ -1,10 +1,9 @@
import React from 'react'; import React, { PropTypes } from 'react';
class LoginForm extends React.Component { function LoginForm(props) {
render() { const { fields: { email, password }, handleSubmit } = props;
const { fields: { email, password }, handleSubmit } = this.props;
return ( return (
<form className="login-form" onSubmit={handleSubmit(this.props.loginUser.bind(this))}> <form className="login-form" onSubmit={handleSubmit(props.loginUser.bind(this))}>
<p className="login-form__field"> <p className="login-form__field">
<label className="login-form__email-label" htmlFor="email">Email:</label> <label className="login-form__email-label" htmlFor="email">Email:</label>
<input <input
@ -28,7 +27,15 @@ class LoginForm extends React.Component {
<input type="submit" value="Login" /> <input type="submit" value="Login" />
</form> </form>
); );
}
} }
LoginForm.propTypes = {
fields: PropTypes.shape({
username: PropTypes.string.isRequired,
password: PropTypes.string.isRequired
}).isRequired,
handleSubmit: PropTypes.func.isRequired,
loginUser: PropTypes.func.isRequired
};
export default LoginForm; export default LoginForm;