Last active
August 31, 2017 19:33
-
-
Save andrerfneves/254ca1f7ce8868bad409d14be9af566d to your computer and use it in GitHub Desktop.
MainTileContainer: Container in a React Native application that handles business logic and mapping of application state to props. This leverages HOC components (redux's `connect`) for abstracting common logic between components.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
import { connect } from 'react-redux'; | |
import MainTileScreen from '../../screens/main-tile/main-tile'; | |
import { fetchPageData } from '../../actions/api/page/fetch-page-data'; | |
import { navigateToRoute } from '../../actions/navigation/navigate-to-route'; | |
import { showModal } from '../../actions/navigation/show-modal'; | |
import { toggleDrawer } from '../../actions/navigation/toggle-drawer'; | |
const mapStateToProps = (state: Object) => ({ | |
nav: state.nav, | |
navbar: state.mainNavbar, | |
pageData: state.pages, | |
secondaryNavigation: state.secondaryNavigation, | |
}); | |
const mapDispatchToProps = (dispatch: Function) => ({ | |
fetchPageData: (pagePath) => dispatch(fetchPageData(pagePath)), | |
navigateToRoute: (routeObj, navigator) => dispatch(navigateToRoute(routeObj, navigator)), | |
showModal: (routeObj, navigator) => dispatch(showModal(routeObj, navigator)), | |
toggleDrawer: (navigator) => dispatch(toggleDrawer(navigator)), | |
}); | |
export default connect( | |
mapStateToProps, | |
mapDispatchToProps, | |
)(MainTileScreen); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment