Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working todo after store mutating in reducer bug: reduxjs/redux#585
- Loading branch information
Showing
11 changed files
with
88 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
|
||
const Todo = ({ onClick, completed, text }) => ( | ||
<li | ||
onClick={onClick} | ||
style={{ | ||
textDecoration: completed ? 'line-through' : 'none' | ||
}} | ||
> | ||
{text} | ||
</li> | ||
) | ||
|
||
class Todo extends React.Component { | ||
render() { | ||
return (<li | ||
onClick={this.props.onClick} | ||
style={{ | ||
textDecoration: this.props.isDone ? 'line-through' : 'none' | ||
}}> | ||
{this.props.text} | ||
</li>) | ||
} | ||
} | ||
|
||
Todo.propTypes = { | ||
onClick: PropTypes.func.isRequired, | ||
completed: PropTypes.bool.isRequired, | ||
text: PropTypes.string.isRequired | ||
onClick: PropTypes.func.isRequired, | ||
isDone: PropTypes.bool.isRequired, | ||
text: PropTypes.string.isRequired | ||
} | ||
|
||
export default Todo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
|
||
import VisibleTodoList from './VisibleTodoList'; | ||
import Footer from './Footer'; | ||
import AddTodoContainer from './AddTodo'; | ||
|
||
export { Footer }; | ||
export { Footer, AddTodoContainer }; | ||
export default VisibleTodoList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters