Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { partial } from '_';
- import API from './API';
- export default React.createClass({
- getInitialState() {
- return {
- username: '',
- password: '',
- };
- },
- handleChange(fieldName, {target: {value}}) {
- this.setState({[fieldName]: value});
- },
- handleSave(evt) {
- evt.preventDefault();
- API.login(this.state);
- },
- render() {
- return (
- <form onSubmit={this.handleSave}>
- <input
- onChange={partial(this.handleChange, 'username')}
- placeholder="Username"
- value={this.state.username}
- />
- <input
- onChange={partial(this.handleChange, 'password')}
- placeholder="Password"
- type="password"
- value={this.state.password}
- />
- <button type="submit">
- Login
- </button>
- </form>
- );
- },
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement