add proptypes to login form
This commit is contained in:
parent
7a07d5380d
commit
29013b99f1
1 changed files with 37 additions and 30 deletions
|
@ -1,34 +1,41 @@
|
|||
import React from 'react';
|
||||
import React, { PropTypes } from 'react';
|
||||
|
||||
class LoginForm extends React.Component {
|
||||
render() {
|
||||
const { fields: { email, password }, handleSubmit } = this.props;
|
||||
return (
|
||||
<form className="login-form" onSubmit={handleSubmit(this.props.loginUser.bind(this))}>
|
||||
<p className="login-form__field">
|
||||
<label className="login-form__email-label" htmlFor="email">Email:</label>
|
||||
<input
|
||||
className="login-form__email-input"
|
||||
id="email"
|
||||
type="text"
|
||||
placeholder="Email"
|
||||
{...email}
|
||||
/>
|
||||
</p>
|
||||
<p className="login-form__field">
|
||||
<label className="signup-form__password-label" htmlFor="password">Password:</label>
|
||||
<input
|
||||
className="signup-form__password-input"
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
{...password}
|
||||
/>
|
||||
</p>
|
||||
<input type="submit" value="Login" />
|
||||
</form>
|
||||
);
|
||||
}
|
||||
function LoginForm(props) {
|
||||
const { fields: { email, password }, handleSubmit } = props;
|
||||
return (
|
||||
<form className="login-form" onSubmit={handleSubmit(props.loginUser.bind(this))}>
|
||||
<p className="login-form__field">
|
||||
<label className="login-form__email-label" htmlFor="email">Email:</label>
|
||||
<input
|
||||
className="login-form__email-input"
|
||||
id="email"
|
||||
type="text"
|
||||
placeholder="Email"
|
||||
{...email}
|
||||
/>
|
||||
</p>
|
||||
<p className="login-form__field">
|
||||
<label className="signup-form__password-label" htmlFor="password">Password:</label>
|
||||
<input
|
||||
className="signup-form__password-input"
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="Password"
|
||||
{...password}
|
||||
/>
|
||||
</p>
|
||||
<input type="submit" value="Login" />
|
||||
</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;
|
||||
|
|
Loading…
Reference in a new issue