mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-28 12:25:21 +08:00
Add isFocused helper to navigation and fix withNavigationFocus (1.x branch) (#3651)
* Add isFocused helper to navigation and fix withNavigationFocus accordingly * Fix snapshots * Make flow pass on TabsWithNavigationFocus example
This commit is contained in:
@@ -109,6 +109,12 @@ class CardStack extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
_isRouteFocused = route => {
|
||||
const { state } = this.props.navigation;
|
||||
const focusedRoute = state.routes[state.index];
|
||||
return route === focusedRoute;
|
||||
};
|
||||
|
||||
_getScreenDetails = scene => {
|
||||
const { screenProps, transitionProps: { navigation }, router } = this.props;
|
||||
let screenDetails = this._screenDetails[scene.key];
|
||||
@@ -123,6 +129,7 @@ class CardStack extends React.Component {
|
||||
const screenNavigation = addNavigationHelpers({
|
||||
dispatch: navigation.dispatch,
|
||||
state: scene.route,
|
||||
isFocused: this._isRouteFocused.bind(this, scene.route),
|
||||
addListener: this._childEventSubscribers[scene.route.key],
|
||||
});
|
||||
screenDetails = {
|
||||
|
||||
Reference in New Issue
Block a user