Jo Ko Jo Ko - 1 year ago 152
React JSX Question

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
is set up like so:

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

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

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download