-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddTodo.js
34 lines (28 loc) · 857 Bytes
/
AddTodo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';
import { connect } from 'react-redux';
import { Button } from 'react-bootstrap';
import * as Actions from '../../actions';
class AddTodo extends React.Component {
dispatch = undefined;
input = undefined;
constructor(props) {
super(props);
this.dispatch = props.dispatch;
this.addTodo = this.addTodo.bind(this);
}
addTodo(){
this.dispatch(Actions.addTodo(this.input.value));
this.input.value = '';
}
render() {
return (
<div>
<input type="text" placeholder="Nowe zadanie..." ref={e => this.input = e} />
{' '}
<Button bsSize="small" onClick={this.addTodo}>Dodaj</Button>
</div>
);
}
}
let AddTodoContainer = connect()(AddTodo);
export default AddTodoContainer;