mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-25 01:28:16 +00:00
Make future proof (and also fix it for the current beta) (#322)
This commit is contained in:
parent
02a388073c
commit
e30ac63f79
@ -33,6 +33,7 @@ AppNavigator.prototype.componentDidUpdate = function(prevProps, prevState) {
|
|||||||
When using Redux, `screenTracking` can be written as a Redux middleware.
|
When using Redux, `screenTracking` can be written as a Redux middleware.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
import { NavigationActions } from 'react-navigation';
|
||||||
import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge';
|
import { GoogleAnalyticsTracker } from 'react-native-google-analytics-bridge';
|
||||||
|
|
||||||
const tracker = new GoogleAnalyticsTracker(GA_TRACKING_ID);
|
const tracker = new GoogleAnalyticsTracker(GA_TRACKING_ID);
|
||||||
@ -45,7 +46,7 @@ function getCurrentScreen(getStateFn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const screenTracking = ({ getState }) => next => (action) => {
|
const screenTracking = ({ getState }) => next => (action) => {
|
||||||
if (action.type !== 'Navigate' && action.type !== 'Back') return next(action);
|
if (action.type !== NavigationActions.NAVIGATE && action.type !== NavigationActions.BACK)) return next(action);
|
||||||
|
|
||||||
const currentScreen = getCurrentScreen(getState);
|
const currentScreen = getCurrentScreen(getState);
|
||||||
const result = next(action);
|
const result = next(action);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user