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,34 +1,41 @@
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(props.loginUser.bind(this))}>
<form className="login-form" onSubmit={handleSubmit(this.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 className="login-form__email-input"
className="login-form__email-input" id="email"
id="email" type="text"
type="text" placeholder="Email"
placeholder="Email" {...email}
{...email} />
/> </p>
</p> <p className="login-form__field">
<p className="login-form__field"> <label className="signup-form__password-label" htmlFor="password">Password:</label>
<label className="signup-form__password-label" htmlFor="password">Password:</label> <input
<input className="signup-form__password-input"
className="signup-form__password-input" id="password"
id="password" type="password"
type="password" placeholder="Password"
placeholder="Password" {...password}
{...password} />
/> </p>
</p> <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;