React Native/Redux 和 react-native-router-flux:为什么 Actions.key 不能在 action creator 中工作?

React Native/Redux and react-native-router-flux: Why doesn't Actions.key work inside an action creator?

将 React Native 和 react-native-router-flux 与 redux 结合使用,我有一个 action creator,我尝试在内部使用 Actions.key,在本例中为 Actions.home,但它不起作用。我可能做错了什么?

这是我的动作创作者:

import * as actionTypes from './actionTypes'
import { Actions } from 'react-native-router-flux'

export const navigateHome = (text) => {
  Actions.home //This does not work for some reason

  return {
    type: actionTypes.NAVIGATE_HOME_SUCCESS,
  }
}

我的主页 <Scene/> 设置如下:

const RouterWithRedux = connect()(Router)
const store = configureStore()

export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <RouterWithRedux>
          <Scene key='root'>
            <Scene component={Login} initial={true} key='login' title='Login'/>
            <Scene component={Home} key='home' title='Home' type={ActionConst.REPLACE}/>
          </Scene>
        </RouterWithRedux>
      </Provider>
    )
  }
}

但是当我在使用 <Text onPress={Actions.home}>Continue</Text> 的组件内部进行测试时,它导航到 <Home/> 很好。

您需要在 navigateHome 中调用 Actions.home(),您不能在没有 () 的情况下只调用 Actions.home