Skip to content

Instantly share code, notes, and snippets.

@josev55
Created May 9, 2017 13:50
Show Gist options
  • Save josev55/0448aa37cd8a23142c7d96fb9b064708 to your computer and use it in GitHub Desktop.
Save josev55/0448aa37cd8a23142c7d96fb9b064708 to your computer and use it in GitHub Desktop.
import React from 'react';
import { RootAndroid } from '../routes.config.android';
import { RootIOS } from '../routes.config.ios';
import { Platform } from 'react-native';
import { connect } from 'react-redux';
import { addNavigationHelpers } from 'react-navigation';
class Nav extends React.Component {
render() {
const { dispatch, navigationState } = this.props;
if (Platform.OS === 'ios') {
return <RootIOS navigation={addNavigationHelpers({ dispatch, state: navigationState })} />;
} else {
return <RootAndroid navigation={addNavigationHelpers({ dispatch, state: navigationState })} />;
}
}
}
const mapStateToProps = (state) =>
{
return {
navigationState: state.nav
}
}
Nav.propTypes = {
dispatch: React.PropTypes.func,
navigationState: React.PropTypes.object
}
export default connect(mapStateToProps)(Nav);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment