Jo Ko
Jo Ko

Reputation: 7575

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

Using React Native and react-native-router-flux with redux, I have an action creator and inside I tried using Actions.key, in this case Actions.home, but it does not work. What could I be doing wrong?

Here is my action creator:

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,
  }
}

And my Home <Scene/> is set up like so:

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>
    )
  }
}

But when I tested inside a component with <Text onPress={Actions.home}>Continue</Text>, it navigated to <Home/> fine.

Upvotes: 0

Views: 192

Answers (1)

rclai
rclai

Reputation: 1890

You need to call Actions.home() in navigateHome, you cannot just do Actions.home without the ().

Upvotes: 1

Related Questions