Skip to content

Instantly share code, notes, and snippets.

@vdeep
Created March 23, 2018 08:14
Show Gist options
  • Save vdeep/3b2c88db3b7b4e7df3624fb43da6b7ee to your computer and use it in GitHub Desktop.
Save vdeep/3b2c88db3b7b4e7df3624fb43da6b7ee to your computer and use it in GitHub Desktop.
Fix for undefined error when starting react-native app with ignite boilerplate
import React from 'react'
import * as ReactNavigation from 'react-navigation'
import { connect } from 'react-redux'
import AppNavigation from './AppNavigation'
// for react-navigation 1.0.0-beta.30
import {
createReduxBoundAddListener,
createReactNavigationReduxMiddleware,
} from 'react-navigation-redux-helpers';
const middleware = createReactNavigationReduxMiddleware(
"root",
state => state.nav,
);
const addListener = createReduxBoundAddListener("root");
// end for react-navigation 1.0.0-beta.30
function ReduxNavigation (props) {
const { dispatch, nav } = props
const navigation = ReactNavigation.addNavigationHelpers({
dispatch,
state: nav,
addListener // <-- add this as well
})
return <AppNavigation navigation={navigation} />
}
const mapStateToProps = state => ({ nav: state.nav })
export default connect(mapStateToProps)(ReduxNavigation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment