Fix convert undefined to object

Trying to execute `Object.keys` in `undefined` throws an error. Defaulting the value to an empty object returns an empty array.
This commit is contained in:
Arthur Denner
2019-03-04 15:32:34 -03:00
committed by GitHub
parent a4097d417c
commit 826dcb467f

View File

@@ -3,7 +3,7 @@ import { TodoListItem } from './TodoListItem';
export class TodoList extends React.Component<any, any> {
render() {
const { filter, todos } = this.props;
const { filter, todos = {} } = this.props;
// filteredTodos returns an array of filtered todo keys [01,02,03]
const filteredTodos = Object.keys(todos).filter(id => {