Compare commits

..

2 Commits

Author SHA1 Message Date
Satyajit Sahoo
1a6f4a581f chore: publish
- react-navigation-stack@2.8.1
2020-06-25 03:02:46 +02:00
Satyajit Sahoo
2e7f4a6d10 fix: pop with correct key from nested stack 2020-06-25 03:01:47 +02:00
3 changed files with 20 additions and 7 deletions

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.8.1](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.8.0...react-navigation-stack@2.8.1) (2020-06-25)
### Bug Fixes
* pop with correct key from nested stack ([2e7f4a6](https://github.com/react-navigation/react-navigation-stack/commit/2e7f4a6d10a00930bd5c53ef6f4bf964c9638db5))
# [2.8.0](https://github.com/react-navigation/react-navigation-stack/compare/react-navigation-stack@2.7.0...react-navigation-stack@2.8.0) (2020-06-25)

View File

@@ -1,6 +1,6 @@
{
"name": "react-navigation-stack",
"version": "2.8.0",
"version": "2.8.1",
"description": "Stack navigator component for React Navigation",
"main": "lib/commonjs/index.js",
"module": "lib/module/index.js",

View File

@@ -47,12 +47,14 @@ const Header = React.memo(function Header(props: StackHeaderProps) {
// eslint-disable-next-line react-hooks/exhaustive-deps
const goBack = React.useCallback(
debounce(() => {
if (navigation.isFirstRouteInParent()) {
// If we're the first route, we're going back to a parent navigator
// So we can't specify a key here
navigation.dispatch(StackActions.pop());
} else {
navigation.dispatch(StackActions.pop({ key: scene.route.key }));
const key = navigation.isFirstRouteInParent()
? // If we're the first route, we're going back to a parent navigator
// So we need to get the key of the route we're nested in
navigation.dangerouslyGetParent()?.state.key
: scene.route.key;
if (key !== undefined) {
navigation.dispatch(StackActions.pop({ key }));
}
}, 50),
[navigation, scene.route.key]