Compare commits

...

2 Commits

Author SHA1 Message Date
Satyajit Sahoo
c4d2a8a828 chore: publish
- @react-navigation/stack@5.6.1
2020-06-25 11:45:59 +02:00
Satyajit Sahoo
fc95d7a256 fix: fix showing back button with headerMode=screen. fixes #8508 2020-06-25 11:42:19 +02:00
5 changed files with 23 additions and 27 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.
## [5.6.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.6.0...@react-navigation/stack@5.6.1) (2020-06-25)
### Bug Fixes
* fix showing back button with headerMode=screen. fixes [#8508](https://github.com/react-navigation/react-navigation/issues/8508) ([fc95d7a](https://github.com/react-navigation/react-navigation/commit/fc95d7a256846b6a4fa999fbbe3fed2051972b42))
# [5.6.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.5.1...@react-navigation/stack@5.6.0) (2020-06-24)

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/stack",
"description": "Stack navigator component for iOS and Android with animated transitions and gestures",
"version": "5.6.0",
"version": "5.6.1",
"keywords": [
"react-native-component",
"react-component",

View File

@@ -32,7 +32,6 @@ export type Props = {
scenes: (Scene<Route<string>> | undefined)[];
getPreviousScene: (props: {
route: Route<string>;
index: number;
}) => Scene<Route<string>> | undefined;
getFocusedRoute: () => Route<string>;
onContentHeightChange?: (props: {
@@ -79,10 +78,7 @@ export default function HeaderContainer({
const isFocused = focusedRoute.key === scene.route.key;
const previous =
getPreviousScene({
route: scene.route,
index: i,
}) ?? parentPreviousScene;
getPreviousScene({ route: scene.route }) ?? parentPreviousScene;
// If the screen is next to a headerless screen, we need to make the header appear static
// This makes the header look like it's moving with the screen

View File

@@ -32,7 +32,6 @@ type Props = TransitionPreset & {
cardStyle?: StyleProp<ViewStyle>;
getPreviousScene: (props: {
route: Route<string>;
index: number;
}) => Scene<Route<string>> | undefined;
getFocusedRoute: () => Route<string>;
renderHeader: (props: HeaderContainerProps) => React.ReactNode;
@@ -162,7 +161,7 @@ function CardContainer({
const isParentHeaderShown = React.useContext(HeaderShownContext);
const isCurrentHeaderShown = headerMode !== 'none' && headerShown !== false;
const previousScene = getPreviousScene({ route: scene.route, index });
const previousScene = getPreviousScene({ route: scene.route });
return (
<Card

View File

@@ -336,31 +336,21 @@ export default class CardStack extends React.Component<Props, State> {
return state.routes[state.index];
};
private getPreviousScene = ({
route,
index,
}: {
route: Route<string>;
index: number;
}) => {
const previousRoute = this.props.getPreviousRoute({ route });
private getPreviousScene = ({ route }: { route: Route<string> }) => {
const { getPreviousRoute } = this.props;
const { scenes } = this.state;
let previous: Scene<Route<string>> | undefined;
const previousRoute = getPreviousRoute({ route });
if (previousRoute) {
// The previous scene will be shortly before the current scene in the array
// So loop back from current index to avoid looping over the full array
for (let j = index - 1; j >= 0; j--) {
const s = this.state.scenes[j];
const previousScene = scenes.find(
(scene) => scene.route.key === previousRoute.key
);
if (s && s.route.key === previousRoute.key) {
previous = s;
break;
}
}
return previousScene;
}
return previous;
return undefined;
};
render() {