0
对不起,我可以看到这个问题已经ben问了几次。我之前已经解决了这个问题,但知道我正在以一种新的方式看到它。`this.setState`不是一个绑定函数中的函数
这是我在店里通量构造:
class TodoStore extends EventEmitter {
constructor() {
super()
this.state = {
todos: [
{
id: uuid(),
text: 'Go Shopping',
complete: false
},
{
id: uuid(),
text: 'Pay Water Bill',
complete: false
},
],
showCompletedTodos: true,
showIncompletedTodos: true
}
this.deleteTodo = this.deleteTodo.bind(this)
this.toggleTodo = this.toggleTodo.bind(this)
this.toggleShowCompletedTodos = this.toggleShowCompletedTodos.bind(this)
this.toggleShowIncompletedTodos = this.toggleShowIncompletedTodos.bind(this)
}
这里有几个我在孩子组件通过TodoActions.fuctionName调用功能:
我得到Uncaught TypeError: this.setState is not a function
当我触发这个功能。
在功能过去结合this
在构造解决了这一点,但在这一点,是不工作
这是我的全球化志愿服务青年: this.setState is not a function
是因为它是一个流量店而不是一个普通的班级?
你是如何在父母/孩子的组件中传递/接收它们的? –
https://gist.github.com/WebRuin/42f3e71d73ef1c5d85be912620de9e65 – Tithos
via https://gist.github.com/WebRuin/9e2bd7aaecea89f60b1ae7f0e4e4c2d7 – Tithos