react-navigation / redux-helpers

Redux middleware and utils for React Navigation
Other
296 stars 43 forks source link

How can i get dispatch() from reduxifyNavigator with setTopLevelNavigator #71

Closed ddthuan87 closed 5 years ago

ddthuan87 commented 5 years ago

Hi! Thank for the Lib!

### Description ### I'm writing a GA tracking for my app.

Before adding GA, Im using "Navigating without the navigation prop" for top level app https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html

App.js


import Router from './app/config/routes';

export default class App extends Component { render() { return (

{ NavigationService.setTopLevelNavigator(navigatorRef); }} />
    );
}

}


With that, i got a setTopLevelNavigator (NavigationContainer dispatch() for all Navigation Service)

> ![screen shot 2018-12-20 at 10 25 44 am](https://user-images.githubusercontent.com/30521011/50262086-ee5d7b80-0441-11e9-828c-39cff2976f14.png)

### **### issue ###**
And now, im using reduxifyNavigator, i can not get a dispatch() setTopLevelNavigator for all navigation service

> routerWrapper.js

import { reduxifyNavigator } from 'react-navigation-redux-helpers'; import { connect } from 'react-redux'; import Router from '../config/routes';

const App = reduxifyNavigator(Router, "root");

const mapStateToProps = (state) => ({ state: state.nav, }); const AppWithNavigationState = connect(mapStateToProps)(App);

export default AppWithNavigationState;


> App.js

import WrapperRouter from './app/googleAnalytics/routerWrapper';

const store = getStore();

export default class App extends Component { render() { return (

{ console.log(navigatorRef); NavigationService.setTopLevelNavigator(navigatorRef); }} />
    );
}

}


> ![screen shot 2018-12-20 at 10 38 37 am](https://user-images.githubusercontent.com/30521011/50262362-76905080-0443-11e9-8ded-0520dab57583.png)

And last, react Navigation add Listener not working with reduxifyNavigator

componentDidMount(){ this.props.navigation.addListener('willFocus', () => { this._handleDefaultLoad(); }); }



### SUMMARY
> **How can i get dispatch() from reduxifyNavigator set top level and react navigation add listener working**
Ashoat commented 5 years ago

I can investigate further if you can provide an MCVE that reproduces the issue, in the form of an Expo Snack or a react-native init'd repo hosted on GitHub.

ddthuan87 commented 5 years ago

I can investigate further if you can provide an MCVE that reproduces the issue, in the form of an Expo Snack or a react-native init'd repo hosted on GitHub.

OKAY, i will push it, thank for reply

murrayee commented 5 years ago

Hi, I have same issue ,How do you solve in the end?

quy-ho-dh commented 5 years ago

Do you have any update?

ddthuan87 commented 5 years ago

Do you have any update?

mình không dùng nó nữa cậu ạ

quy-ho-dh commented 5 years ago

Did you have another good solution?

ddthuan87 commented 5 years ago

Did you have another good solution?

are u using this lib for what?