0
我開發了todo reactjs應用程序的reducer。這是減速機的一部分:爲什麼會出現TypeError:無法讀取未完成的屬性undefined?
case "SHOWCOMPLETE":
//todo remove
debugger;
return state.map(todo => {
if (todo.completed) {
return todo
}
else
{}
})
這是顯示已完成的待辦事項:true。然而,todos組件將這個錯誤渲染出來。這是組件的一部分:
if (this.props.todos) {
//todo remove
console.log('testing=this.props', this.props);
display = this.props.todos.map
(
(todo) => (
<p className={todo.completed ? 'strikethrough' : ''}
onClick={() => this.complete(todo.name)}> {todo.name}!</p>
)
)
}
爲什麼我得到這個錯誤?這裏是一個github鏈接:github