mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
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:
@@ -3,7 +3,7 @@ import { TodoListItem } from './TodoListItem';
|
|||||||
|
|
||||||
export class TodoList extends React.Component<any, any> {
|
export class TodoList extends React.Component<any, any> {
|
||||||
render() {
|
render() {
|
||||||
const { filter, todos } = this.props;
|
const { filter, todos = {} } = this.props;
|
||||||
|
|
||||||
// filteredTodos returns an array of filtered todo keys [01,02,03]
|
// filteredTodos returns an array of filtered todo keys [01,02,03]
|
||||||
const filteredTodos = Object.keys(todos).filter(id => {
|
const filteredTodos = Object.keys(todos).filter(id => {
|
||||||
|
|||||||
Reference in New Issue
Block a user