导入另一个模块的操作时发生错误

时间:2018-02-09 10:42:38

标签: reactjs redux react-redux

我正在编写单页应用程序。由于此应用程序在rootApp上更新页面,因此rootApp的某些操作计划由其他页面使用,例如redirectPageTo。我直接使用import和export来尝试直接调度RootApp的动作,但是编译错误发生了。错误是未定义的,但实际上它在同一个文件中定义良好。有没有正确的方法来做到这一点?欢迎任何想法。

//this page is the page other than RootApp; here is the LoginPage reducer
import {redirectPageTo} from './RootAppAction.jsx';//import actions, with this line, errors like defaultState undefined happens

const defaultState={(some states declaration)};
export function updateLoginPageState(state={},action) {
  ...
  dispatch(redirectPageTo("HOMEPAGE"));//use other module's action. Can I use it in this way?
}

1 个答案:

答案 0 :(得分:0)

我发现根本原因可能与我将reducer和动作代码放在同一个文件中有关。