React native alt dispatcher this.dispatch 不是函数 Babel 6
React native alt dispatcher this.dispatch is not a function Babel 6
我今天早上将我的项目从 RN 0.15.0 升级到 0.16.0,并且由于传递到 Babel 6 而出现了很多错误。
有一个我不明白(我猜它在我的 .babelrc 文件中丢失了一些东西)
此代码在升级前运行良好:
'use strict';
import alt from '../alt';
import MeStore from '../stores/Me';
export class MeActions {
showedCurrentPosition(showed) {
this.dispatch(showed);
}
}
export default alt.createActions(MeActions);
这是我使用插件 alt 的 Alt.js 文件:
'use strict';
import Alt from 'alt';
export default new Alt();
现在,当 运行 我的代码 "this.dispatch is not a function" 调用 MeActions.showedCurrentPosition(true);
时,我得到了
您可能最终也升级了 Alt。最近的一个版本取消了 dispatch,取而代之的是简单 returns。查看有关操作的文档 http://alt.js.org/docs/createActions/
嗯,如果我们必须 return 从操作中分派它,我们应该如何在异步操作开始之前分派它?
我过去常常在操作开始时分派,然后 运行 异步内容并在成功或失败处理程序中分派以再次更新状态。
我今天早上将我的项目从 RN 0.15.0 升级到 0.16.0,并且由于传递到 Babel 6 而出现了很多错误。 有一个我不明白(我猜它在我的 .babelrc 文件中丢失了一些东西)
此代码在升级前运行良好:
'use strict';
import alt from '../alt';
import MeStore from '../stores/Me';
export class MeActions {
showedCurrentPosition(showed) {
this.dispatch(showed);
}
}
export default alt.createActions(MeActions);
这是我使用插件 alt 的 Alt.js 文件:
'use strict';
import Alt from 'alt';
export default new Alt();
现在,当 运行 我的代码 "this.dispatch is not a function" 调用 MeActions.showedCurrentPosition(true);
您可能最终也升级了 Alt。最近的一个版本取消了 dispatch,取而代之的是简单 returns。查看有关操作的文档 http://alt.js.org/docs/createActions/
嗯,如果我们必须 return 从操作中分派它,我们应该如何在异步操作开始之前分派它?
我过去常常在操作开始时分派,然后 运行 异步内容并在成功或失败处理程序中分派以再次更新状态。