Advertisement
Guest User

Untitled

a guest
Mar 29th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React from 'react'
  2. import * as ReactNavigation from 'react-navigation'
  3. import { connect } from 'react-redux'
  4. import AppNavigation from './AppNavigation'
  5.  
  6. // for react-navigation 1.0.0-beta.30
  7. import {
  8.   createReduxBoundAddListener,
  9.   createReactNavigationReduxMiddleware,
  10. } from 'react-navigation-redux-helpers';
  11.  
  12. const middleware = createReactNavigationReduxMiddleware(
  13.   "root",
  14.   state => state.nav,
  15. );
  16. const addListener = createReduxBoundAddListener("root");
  17. // end for react-navigation 1.0.0-beta.30
  18.  
  19.  
  20. function ReduxNavigation (props) {
  21.   const { dispatch, nav } = props
  22.   const navigation = ReactNavigation.addNavigationHelpers({
  23.     dispatch,
  24.     state: nav,
  25.     addListener // <-- add this as well
  26.   })
  27.  
  28.   return <AppNavigation navigation={navigation} />
  29. }
  30.  
  31. const mapStateToProps = state => ({ nav: state.nav })
  32. export default connect(mapStateToProps)(ReduxNavigation)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement