forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
navigation: Upgrade to React Navigation v2
Upgrade to React Navigation 2 and do the minimal changes that make our code compatible. Navigating behavior has changed, and pushing a route with the same key does not result in duplicated entry in the history. Fixes zulip#2682 The code to wire RN navigator to Redux have changed. The newer approach is simpler, just using `reduxifyNavigator` helper does most of the work.
- Loading branch information
1 parent
e9fe1e8
commit 4b76ba6
Showing
4 changed files
with
102 additions
and
56 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,13 @@ | ||
/* @flow */ | ||
import { connect } from 'react-redux'; | ||
import { reduxifyNavigator } from 'react-navigation-redux-helpers'; | ||
|
||
import React, { PureComponent } from 'react'; | ||
import { addNavigationHelpers } from 'react-navigation'; | ||
import { createReduxBoundAddListener } from 'react-navigation-redux-helpers'; | ||
|
||
import type { Dispatch, GlobalState } from '../types'; | ||
import type { GlobalState } from '../types'; | ||
import { getNav } from '../selectors'; | ||
import AppNavigator from './AppNavigator'; | ||
|
||
type Props = { | ||
dispatch: Dispatch, | ||
nav: Object, | ||
}; | ||
|
||
class AppWithNavigation extends PureComponent<Props> { | ||
props: Props; | ||
|
||
render() { | ||
const { dispatch, nav } = this.props; | ||
const addListener = createReduxBoundAddListener('root'); | ||
|
||
return ( | ||
// $FlowFixMe-56 flow-typed object type is incompatible with statics of React.Component | ||
<AppNavigator | ||
navigation={addNavigationHelpers({ | ||
state: nav, | ||
dispatch, | ||
addListener, | ||
})} | ||
/> | ||
); | ||
} | ||
} | ||
const AppWithNavigation = reduxifyNavigator(AppNavigator, 'root'); | ||
|
||
export default connect((state: GlobalState) => ({ | ||
nav: getNav(state), | ||
state: getNav(state), | ||
}))(AppWithNavigation); |
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