【发布时间】:2020-09-17 05:44:20
【问题描述】:
我是 Flux 和 react 的新手,我想知道如何访问 calculatestate() 中的状态 componentdidmount()?
如何访问 componentdidmount() 中的事件状态?我想遍历事件,然后为每个事件运行一个查询,这反过来又更新另一个商店。
static getStores() {
return [SomeStore];
}
static calculateState(prevState, props) {
const somestore = SomeStore.getState();
return {
events: SomeStore.getState(),
};
}
componentdidmount(){
//this.state.events;
//need to do some query based on the events
//this query will update another store.
}
【问题讨论】:
-
这里有更新吗?
-
目前没有更新。我尝试使用 Flux 和 Flux 容器创建一个简单的 React 应用程序,但在使用 Flux 容器时它给了我一个错误。像这样的东西:你需要声明 .... 使用 new 关键字..