Compare commits

..

5 Commits

Author SHA1 Message Date
Satyajit Sahoo
50a161dc3d chore: publish
- @react-navigation/bottom-tabs@5.10.7
 - @react-navigation/compat@5.3.7
 - @react-navigation/core@5.14.1
 - @react-navigation/devtools@5.1.15
 - @react-navigation/drawer@5.10.7
 - @react-navigation/material-bottom-tabs@5.3.7
 - @react-navigation/material-top-tabs@5.3.7
 - @react-navigation/native@5.8.7
 - @react-navigation/routers@5.6.1
 - @react-navigation/stack@5.12.4
2020-11-08 09:06:37 +01:00
Satyajit Sahoo
360b0e9958 fix: tweak error message when navigator has non-screen children 2020-11-07 16:43:45 +01:00
Satyajit Sahoo
e50c8aa942 refactor: use a regular action for 'resetRoot'
Previously, 'resetRoot' directly performed a 'setState' on the container instead of dispatching an action. This meant that hooks such as listener for 'preventRemove' won't be notified by it. This commit changes it to dispatch a regular 'RESET' action which will behave the same as other actions.
2020-11-07 15:55:48 +01:00
Satyajit Sahoo
8f0efc8db5 fix: don't hide child header automatically in stack 2020-11-07 14:39:23 +01:00
Satyajit Sahoo
7de6677e72 chore: fix statusbar height in modal example 2020-11-07 00:34:25 +01:00
35 changed files with 334 additions and 77 deletions

View File

@@ -86,12 +86,18 @@ export default function BottomTabsScreen({
> >
<BottomTabs.Screen <BottomTabs.Screen
name="Article" name="Article"
component={SimpleStackScreen}
options={{ options={{
title: 'Article', title: 'Article',
tabBarIcon: getTabBarIcon('file-document-box'), tabBarIcon: getTabBarIcon('file-document-box'),
}} }}
/> >
{(props) => (
<SimpleStackScreen
{...props}
screenOptions={{ headerShown: false }}
/>
)}
</BottomTabs.Screen>
<BottomTabs.Screen <BottomTabs.Screen
name="Chat" name="Chat"
component={Chat} component={Chat}

View File

@@ -23,13 +23,19 @@ export default function MaterialBottomTabsScreen() {
<MaterialBottomTabs.Navigator barStyle={styles.tabBar}> <MaterialBottomTabs.Navigator barStyle={styles.tabBar}>
<MaterialBottomTabs.Screen <MaterialBottomTabs.Screen
name="Article" name="Article"
component={SimpleStackScreen}
options={{ options={{
tabBarLabel: 'Article', tabBarLabel: 'Article',
tabBarIcon: 'file-document-box', tabBarIcon: 'file-document-box',
tabBarColor: '#C9E7F8', tabBarColor: '#C9E7F8',
}} }}
/> >
{(props) => (
<SimpleStackScreen
{...props}
screenOptions={{ headerShown: false }}
/>
)}
</MaterialBottomTabs.Screen>
<MaterialBottomTabs.Screen <MaterialBottomTabs.Screen
name="Chat" name="Chat"
component={Chat} component={Chat}

View File

@@ -93,7 +93,9 @@ export default function SimpleStackScreen({ navigation, options }: Props) {
cardOverlayEnabled: true, cardOverlayEnabled: true,
gestureEnabled: true, gestureEnabled: true,
headerStatusBarHeight: headerStatusBarHeight:
navigation.dangerouslyGetState().routes.indexOf(route) > 0 navigation
.dangerouslyGetState()
.routes.findIndex((r: any) => r.key === route.key) > 0
? 0 ? 0
: undefined, : undefined,
})} })}

View File

@@ -77,18 +77,28 @@ const InputScreen = ({
e.preventDefault(); e.preventDefault();
Alert.alert( if (Platform.OS === 'web') {
'Discard changes?', const discard = confirm(
'You have unsaved changes. Are you sure to discard them and leave the screen?', 'You have unsaved changes. Discard them and leave the screen?'
[ );
{ text: "Don't leave", style: 'cancel', onPress: () => {} },
{ if (discard) {
text: 'Discard', navigation.dispatch(action);
style: 'destructive', }
onPress: () => navigation.dispatch(action), } else {
}, Alert.alert(
] 'Discard changes?',
); 'You have unsaved changes. Discard them and leave the screen?',
[
{ text: "Don't leave", style: 'cancel', onPress: () => {} },
{
text: 'Discard',
style: 'destructive',
onPress: () => navigation.dispatch(action),
},
]
);
}
}), }),
[hasUnsavedChanges, navigation] [hasUnsavedChanges, navigation]
); );

View File

@@ -4,6 +4,7 @@ import { Button } from 'react-native-paper';
import type { ParamListBase } from '@react-navigation/native'; import type { ParamListBase } from '@react-navigation/native';
import { import {
createStackNavigator, createStackNavigator,
StackNavigationOptions,
StackScreenProps, StackScreenProps,
} from '@react-navigation/stack'; } from '@react-navigation/stack';
import Article from '../Shared/Article'; import Article from '../Shared/Article';
@@ -105,7 +106,10 @@ const SimpleStack = createStackNavigator<SimpleStackParams>();
export default function SimpleStackScreen({ export default function SimpleStackScreen({
navigation, navigation,
}: StackScreenProps<ParamListBase>) { screenOptions,
}: StackScreenProps<ParamListBase> & {
screenOptions?: StackNavigationOptions;
}) {
React.useLayoutEffect(() => { React.useLayoutEffect(() => {
navigation.setOptions({ navigation.setOptions({
headerShown: false, headerShown: false,
@@ -113,7 +117,7 @@ export default function SimpleStackScreen({
}, [navigation]); }, [navigation]);
return ( return (
<SimpleStack.Navigator> <SimpleStack.Navigator screenOptions={screenOptions}>
<SimpleStack.Screen <SimpleStack.Screen
name="Article" name="Article"
component={ArticleScreen} component={ArticleScreen}

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.10.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.10.6...@react-navigation/bottom-tabs@5.10.7) (2020-11-08)
**Note:** Version bump only for package @react-navigation/bottom-tabs
## [5.10.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.10.5...@react-navigation/bottom-tabs@5.10.6) (2020-11-04) ## [5.10.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/bottom-tabs@5.10.5...@react-navigation/bottom-tabs@5.10.6) (2020-11-04)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/bottom-tabs", "name": "@react-navigation/bottom-tabs",
"description": "Bottom tab navigator following iOS design guidelines", "description": "Bottom tab navigator following iOS design guidelines",
"version": "5.10.6", "version": "5.10.7",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -41,7 +41,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.16.2", "@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.6", "@react-navigation/native": "^5.8.7",
"@testing-library/react-native": "^7.1.0", "@testing-library/react-native": "^7.1.0",
"@types/color": "^3.0.1", "@types/color": "^3.0.1",
"@types/react": "^16.9.53", "@types/react": "^16.9.53",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.3.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.6...@react-navigation/compat@5.3.7) (2020-11-08)
**Note:** Version bump only for package @react-navigation/compat
## [5.3.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.5...@react-navigation/compat@5.3.6) (2020-11-04) ## [5.3.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.3.5...@react-navigation/compat@5.3.6) (2020-11-04)
**Note:** Version bump only for package @react-navigation/compat **Note:** Version bump only for package @react-navigation/compat

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/compat", "name": "@react-navigation/compat",
"description": "Compatibility layer to write navigator definitions in static configuration format", "description": "Compatibility layer to write navigator definitions in static configuration format",
"version": "5.3.6", "version": "5.3.7",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -32,7 +32,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.16.2", "@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.6", "@react-navigation/native": "^5.8.7",
"@types/react": "^16.9.53", "@types/react": "^16.9.53",
"react": "~16.13.1", "react": "~16.13.1",
"typescript": "^4.0.3" "typescript": "^4.0.3"

View File

@@ -147,7 +147,6 @@ export default function createCompatNavigationProp<
} }
}, },
state: { state: {
// @ts-expect-error: these properties may actually exist
key: state.key, key: state.key,
// @ts-expect-error // @ts-expect-error
routeName: state.name, routeName: state.name,
@@ -202,7 +201,6 @@ export default function createCompatNavigationProp<
const { routes } = navigation.dangerouslyGetState(); const { routes } = navigation.dangerouslyGetState();
// @ts-expect-error
return routes[0].key === state.key; return routes[0].key === state.key;
}, },
dangerouslyGetParent() { dangerouslyGetParent() {

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.14.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@5.14.0...@react-navigation/core@5.14.1) (2020-11-08)
### Bug Fixes
* tweak error message when navigator has non-screen children ([360b0e9](https://github.com/react-navigation/react-navigation/commit/360b0e995835990c55b75898757ebdd120d52446))
# [5.14.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@5.13.5...@react-navigation/core@5.14.0) (2020-11-04) # [5.14.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/core@5.13.5...@react-navigation/core@5.14.0) (2020-11-04)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/core", "name": "@react-navigation/core",
"description": "Core utilities for building navigators", "description": "Core utilities for building navigators",
"version": "5.14.0", "version": "5.14.1",
"keywords": [ "keywords": [
"react", "react",
"react-native", "react-native",
@@ -35,7 +35,7 @@
"clean": "del lib" "clean": "del lib"
}, },
"dependencies": { "dependencies": {
"@react-navigation/routers": "^5.6.0", "@react-navigation/routers": "^5.6.1",
"escape-string-regexp": "^4.0.0", "escape-string-regexp": "^4.0.0",
"nanoid": "^3.1.15", "nanoid": "^3.1.15",
"query-string": "^6.13.6", "query-string": "^6.13.6",

View File

@@ -160,9 +160,20 @@ const BaseNavigationContainer = React.forwardRef(
const resetRoot = React.useCallback( const resetRoot = React.useCallback(
(state?: PartialState<NavigationState> | NavigationState) => { (state?: PartialState<NavigationState> | NavigationState) => {
setState(state); const target = state?.key ?? keyedListeners.getState.root?.().key;
if (target == null) {
throw new Error(NOT_INITIALIZED_ERROR);
}
listeners.focus[0]((navigation) =>
navigation.dispatch({
...CommonActions.reset(state),
target,
})
);
}, },
[setState] [keyedListeners.getState, listeners.focus]
); );
const getRootState = React.useCallback(() => { const getRootState = React.useCallback(() => {

View File

@@ -1178,3 +1178,149 @@ it("prevents removing by multiple screens with 'beforeRemove' event", () => {
type: 'stack', type: 'stack',
}); });
}); });
it("prevents removing a child screen with 'beforeRemove' event with 'resetRoot'", () => {
const TestNavigator = (props: any) => {
const { state, descriptors } = useNavigationBuilder(StackRouter, props);
return (
<React.Fragment>
{state.routes.map((route) => descriptors[route.key].render())}
</React.Fragment>
);
};
const onBeforeRemove = jest.fn();
let shouldPrevent = true;
let shouldContinue = false;
const TestScreen = (props: any) => {
React.useEffect(
() =>
props.navigation.addListener('beforeRemove', (e: any) => {
onBeforeRemove();
if (shouldPrevent) {
e.preventDefault();
if (shouldContinue) {
props.navigation.dispatch(e.data.action);
}
}
}),
[props.navigation]
);
return null;
};
const onStateChange = jest.fn();
const ref = React.createRef<NavigationContainerRef>();
const element = (
<BaseNavigationContainer ref={ref} onStateChange={onStateChange}>
<TestNavigator>
<Screen name="foo">{() => null}</Screen>
<Screen name="bar">{() => null}</Screen>
<Screen name="baz">
{() => (
<TestNavigator>
<Screen name="qux" component={TestScreen} />
<Screen name="lex">{() => null}</Screen>
</TestNavigator>
)}
</Screen>
</TestNavigator>
</BaseNavigationContainer>
);
render(element);
act(() => ref.current?.navigate('baz'));
expect(onStateChange).toBeCalledTimes(1);
expect(onStateChange).toBeCalledWith({
index: 1,
key: 'stack-2',
routeNames: ['foo', 'bar', 'baz'],
routes: [
{ key: 'foo-3', name: 'foo' },
{
key: 'baz-4',
name: 'baz',
state: {
index: 0,
key: 'stack-6',
routeNames: ['qux', 'lex'],
routes: [{ key: 'qux-7', name: 'qux' }],
stale: false,
type: 'stack',
},
},
],
stale: false,
type: 'stack',
});
act(() =>
ref.current?.resetRoot({
index: 0,
key: 'stack-2',
routeNames: ['foo', 'bar', 'baz'],
routes: [{ key: 'foo-3', name: 'foo' }],
stale: false,
type: 'stack',
})
);
expect(onStateChange).toBeCalledTimes(1);
expect(onBeforeRemove).toBeCalledTimes(1);
expect(ref.current?.getRootState()).toEqual({
index: 1,
key: 'stack-2',
routeNames: ['foo', 'bar', 'baz'],
routes: [
{ key: 'foo-3', name: 'foo' },
{
key: 'baz-4',
name: 'baz',
state: {
index: 0,
key: 'stack-6',
routeNames: ['qux', 'lex'],
routes: [{ key: 'qux-7', name: 'qux' }],
stale: false,
type: 'stack',
},
},
],
stale: false,
type: 'stack',
});
shouldPrevent = false;
act(() =>
ref.current?.resetRoot({
index: 0,
key: 'stack-2',
routeNames: ['foo', 'bar', 'baz'],
routes: [{ key: 'foo-3', name: 'foo' }],
stale: false,
type: 'stack',
})
);
expect(onStateChange).toBeCalledTimes(2);
expect(onStateChange).toBeCalledWith({
index: 0,
key: 'stack-2',
routeNames: ['foo', 'bar', 'baz'],
routes: [{ key: 'foo-3', name: 'foo' }],
stale: false,
type: 'stack',
});
});

View File

@@ -93,7 +93,7 @@ const getRouteConfigsFromChildren = <
`A navigator can only contain 'Screen' components as its direct children (found '${ `A navigator can only contain 'Screen' components as its direct children (found '${
// @ts-expect-error: child can be any type and we're accessing it safely, but TS doesn't understand it // @ts-expect-error: child can be any type and we're accessing it safely, but TS doesn't understand it
child.type?.name ? child.type.name : String(child) child.type?.name ? child.type.name : String(child)
}')` }'). To render this component in the navigator, pass it in the 'component' prop to 'Screen'.`
); );
}, []); }, []);

View File

@@ -90,18 +90,11 @@ export default function useOnAction({
onDispatchAction(action, state === result); onDispatchAction(action, state === result);
if (state !== result) { if (state !== result) {
const nextRouteKeys = (result.routes as any[]).map(
(route: { key?: string }) => route.key
);
const removedRoutes = state.routes.filter(
(route) => !nextRouteKeys.includes(route.key)
);
const isPrevented = shouldPreventRemove( const isPrevented = shouldPreventRemove(
emitter, emitter,
beforeRemoveListeners, beforeRemoveListeners,
removedRoutes, state.routes,
result.routes,
action action
); );

View File

@@ -1,7 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import type { import type {
NavigationState, NavigationState,
Route,
NavigationAction, NavigationAction,
} from '@react-navigation/routers'; } from '@react-navigation/routers';
import NavigationBuilderContext, { import NavigationBuilderContext, {
@@ -22,11 +21,16 @@ const VISITED_ROUTE_KEYS = Symbol('VISITED_ROUTE_KEYS');
export const shouldPreventRemove = ( export const shouldPreventRemove = (
emitter: NavigationEventEmitter<EventMapCore<any>>, emitter: NavigationEventEmitter<EventMapCore<any>>,
beforeRemoveListeners: Record<string, ChildBeforeRemoveListener | undefined>, beforeRemoveListeners: Record<string, ChildBeforeRemoveListener | undefined>,
routes: Route<string>[], currentRoutes: { key: string }[],
nextRoutes: { key?: string | undefined }[],
action: NavigationAction action: NavigationAction
) => { ) => {
const nextRouteKeys = nextRoutes.map((route) => route.key);
// Call these in reverse order so last screens handle the event first // Call these in reverse order so last screens handle the event first
const reversedRoutes = [...routes].reverse(); const removedRoutes = currentRoutes
.filter((route) => !nextRouteKeys.includes(route.key))
.reverse();
const visitedRouteKeys: Set<string> = const visitedRouteKeys: Set<string> =
// @ts-expect-error: add this property to mark that we've already emitted this action // @ts-expect-error: add this property to mark that we've already emitted this action
@@ -37,7 +41,7 @@ export const shouldPreventRemove = (
[VISITED_ROUTE_KEYS]: visitedRouteKeys, [VISITED_ROUTE_KEYS]: visitedRouteKeys,
}; };
for (const route of reversedRoutes) { for (const route of removedRoutes) {
if (visitedRouteKeys.has(route.key)) { if (visitedRouteKeys.has(route.key)) {
// Skip if we've already emitted this action for this screen // Skip if we've already emitted this action for this screen
continue; continue;
@@ -85,6 +89,7 @@ export default function useOnPreventRemove({
emitter, emitter,
beforeRemoveListeners, beforeRemoveListeners,
state.routes, state.routes,
[],
action action
); );
}); });

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.1.15](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@5.1.14...@react-navigation/devtools@5.1.15) (2020-11-08)
**Note:** Version bump only for package @react-navigation/devtools
## [5.1.14](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@5.1.13...@react-navigation/devtools@5.1.14) (2020-11-04) ## [5.1.14](https://github.com/react-navigation/react-navigation/compare/@react-navigation/devtools@5.1.13...@react-navigation/devtools@5.1.14) (2020-11-04)
**Note:** Version bump only for package @react-navigation/devtools **Note:** Version bump only for package @react-navigation/devtools

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/devtools", "name": "@react-navigation/devtools",
"description": "Developer tools for React Navigation", "description": "Developer tools for React Navigation",
"version": "5.1.14", "version": "5.1.15",
"keywords": [ "keywords": [
"react", "react",
"react-native", "react-native",
@@ -36,7 +36,7 @@
"clean": "del lib" "clean": "del lib"
}, },
"dependencies": { "dependencies": {
"@react-navigation/core": "^5.14.0", "@react-navigation/core": "^5.14.1",
"deep-equal": "^2.0.4" "deep-equal": "^2.0.4"
}, },
"devDependencies": { "devDependencies": {

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.10.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.10.6...@react-navigation/drawer@5.10.7) (2020-11-08)
**Note:** Version bump only for package @react-navigation/drawer
## [5.10.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.10.5...@react-navigation/drawer@5.10.6) (2020-11-04) ## [5.10.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/drawer@5.10.5...@react-navigation/drawer@5.10.6) (2020-11-04)
**Note:** Version bump only for package @react-navigation/drawer **Note:** Version bump only for package @react-navigation/drawer

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/drawer", "name": "@react-navigation/drawer",
"description": "Drawer navigator component with animated transitions and gesturess", "description": "Drawer navigator component with animated transitions and gesturess",
"version": "5.10.6", "version": "5.10.7",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -46,7 +46,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.16.2", "@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.6", "@react-navigation/native": "^5.8.7",
"@testing-library/react-native": "^7.1.0", "@testing-library/react-native": "^7.1.0",
"@types/react": "^16.9.53", "@types/react": "^16.9.53",
"@types/react-native": "^0.63.30", "@types/react-native": "^0.63.30",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.3.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.6...@react-navigation/material-bottom-tabs@5.3.7) (2020-11-08)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs
## [5.3.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.5...@react-navigation/material-bottom-tabs@5.3.6) (2020-11-04) ## [5.3.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-bottom-tabs@5.3.5...@react-navigation/material-bottom-tabs@5.3.6) (2020-11-04)
**Note:** Version bump only for package @react-navigation/material-bottom-tabs **Note:** Version bump only for package @react-navigation/material-bottom-tabs

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/material-bottom-tabs", "name": "@react-navigation/material-bottom-tabs",
"description": "Integration for bottom navigation component from react-native-paper", "description": "Integration for bottom navigation component from react-native-paper",
"version": "5.3.6", "version": "5.3.7",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -42,7 +42,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.16.2", "@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.6", "@react-navigation/native": "^5.8.7",
"@testing-library/react-native": "^7.1.0", "@testing-library/react-native": "^7.1.0",
"@types/react": "^16.9.53", "@types/react": "^16.9.53",
"@types/react-native": "^0.63.30", "@types/react-native": "^0.63.30",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.3.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.6...@react-navigation/material-top-tabs@5.3.7) (2020-11-08)
**Note:** Version bump only for package @react-navigation/material-top-tabs
## [5.3.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.5...@react-navigation/material-top-tabs@5.3.6) (2020-11-04) ## [5.3.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/material-top-tabs@5.3.5...@react-navigation/material-top-tabs@5.3.6) (2020-11-04)
**Note:** Version bump only for package @react-navigation/material-top-tabs **Note:** Version bump only for package @react-navigation/material-top-tabs

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/material-top-tabs", "name": "@react-navigation/material-top-tabs",
"description": "Integration for the animated tab view component from react-native-tab-view", "description": "Integration for the animated tab view component from react-native-tab-view",
"version": "5.3.6", "version": "5.3.7",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -45,7 +45,7 @@
}, },
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.16.2", "@react-native-community/bob": "^0.16.2",
"@react-navigation/native": "^5.8.6", "@react-navigation/native": "^5.8.7",
"@testing-library/react-native": "^7.1.0", "@testing-library/react-native": "^7.1.0",
"@types/react": "^16.9.53", "@types/react": "^16.9.53",
"@types/react-native": "^0.63.30", "@types/react-native": "^0.63.30",

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.8.7](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.8.6...@react-navigation/native@5.8.7) (2020-11-08)
**Note:** Version bump only for package @react-navigation/native
## [5.8.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.8.5...@react-navigation/native@5.8.6) (2020-11-04) ## [5.8.6](https://github.com/react-navigation/react-navigation/compare/@react-navigation/native@5.8.5...@react-navigation/native@5.8.6) (2020-11-04)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/native", "name": "@react-navigation/native",
"description": "React Native integration for React Navigation", "description": "React Native integration for React Navigation",
"version": "5.8.6", "version": "5.8.7",
"keywords": [ "keywords": [
"react-native", "react-native",
"react-navigation", "react-navigation",
@@ -37,7 +37,7 @@
"clean": "del lib" "clean": "del lib"
}, },
"dependencies": { "dependencies": {
"@react-navigation/core": "^5.14.0", "@react-navigation/core": "^5.14.1",
"escape-string-regexp": "^4.0.0", "escape-string-regexp": "^4.0.0",
"nanoid": "^3.1.15" "nanoid": "^3.1.15"
}, },

View File

@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.6.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/routers@5.6.0...@react-navigation/routers@5.6.1) (2020-11-08)
**Note:** Version bump only for package @react-navigation/routers
# [5.6.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/routers@5.5.1...@react-navigation/routers@5.6.0) (2020-11-04) # [5.6.0](https://github.com/react-navigation/react-navigation/compare/@react-navigation/routers@5.5.1...@react-navigation/routers@5.6.0) (2020-11-04)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/routers", "name": "@react-navigation/routers",
"description": "Routers to help build custom navigators", "description": "Routers to help build custom navigators",
"version": "5.6.0", "version": "5.6.1",
"keywords": [ "keywords": [
"react", "react",
"react-native", "react-native",

View File

@@ -23,7 +23,7 @@ export type Action =
} }
| { | {
type: 'RESET'; type: 'RESET';
payload: ResetState; payload: ResetState | undefined;
source?: string; source?: string;
target?: string; target?: string;
} }
@@ -62,7 +62,7 @@ export function navigate(...args: any): Action {
} }
} }
export function reset(state: ResetState): Action { export function reset(state: ResetState | undefined): Action {
return { type: 'RESET', payload: state }; return { type: 'RESET', payload: state };
} }

View File

@@ -56,12 +56,11 @@ export type PartialRoute<R extends Route<string>> = Omit<R, 'key'> & {
}; };
export type PartialState<State extends NavigationState> = Partial< export type PartialState<State extends NavigationState> = Partial<
Omit<State, 'stale' | 'type' | 'key' | 'routes' | 'routeNames'> Omit<State, 'stale' | 'routes'>
> & > &
Readonly<{ Readonly<{
stale?: true; stale?: true;
type?: string; routes: PartialRoute<Route<State['routeNames'][number]>>[];
routes: PartialRoute<Route<string>>[];
}>; }>;
export type Route< export type Route<

View File

@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [5.12.4](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.12.3...@react-navigation/stack@5.12.4) (2020-11-08)
### Bug Fixes
* don't hide child header automatically in stack ([8f0efc8](https://github.com/react-navigation/react-navigation/commit/8f0efc8db534297a95ea8a2bcb6d2e387c1fea53))
## [5.12.3](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.12.2...@react-navigation/stack@5.12.3) (2020-11-04) ## [5.12.3](https://github.com/react-navigation/react-navigation/compare/@react-navigation/stack@5.12.2...@react-navigation/stack@5.12.3) (2020-11-04)

View File

@@ -1,7 +1,7 @@
{ {
"name": "@react-navigation/stack", "name": "@react-navigation/stack",
"description": "Stack navigator component for iOS and Android with animated transitions and gestures", "description": "Stack navigator component for iOS and Android with animated transitions and gestures",
"version": "5.12.3", "version": "5.12.4",
"keywords": [ "keywords": [
"react-native-component", "react-native-component",
"react-component", "react-component",
@@ -46,7 +46,7 @@
"devDependencies": { "devDependencies": {
"@react-native-community/bob": "^0.16.2", "@react-native-community/bob": "^0.16.2",
"@react-native-community/masked-view": "^0.1.10", "@react-native-community/masked-view": "^0.1.10",
"@react-navigation/native": "^5.8.6", "@react-navigation/native": "^5.8.7",
"@testing-library/react-native": "^7.1.0", "@testing-library/react-native": "^7.1.0",
"@types/color": "^3.0.1", "@types/color": "^3.0.1",
"@types/react": "^16.9.53", "@types/react": "^16.9.53",

View File

@@ -15,7 +15,6 @@ import {
forNoAnimation, forNoAnimation,
forSlideRight, forSlideRight,
} from '../../TransitionConfigs/HeaderStyleInterpolators'; } from '../../TransitionConfigs/HeaderStyleInterpolators';
import HeaderShownContext from '../../utils/HeaderShownContext';
import PreviousSceneContext from '../../utils/PreviousSceneContext'; import PreviousSceneContext from '../../utils/PreviousSceneContext';
import type { import type {
Layout, Layout,
@@ -56,7 +55,6 @@ export default function HeaderContainer({
style, style,
}: Props) { }: Props) {
const focusedRoute = getFocusedRoute(); const focusedRoute = getFocusedRoute();
const isParentHeaderShown = React.useContext(HeaderShownContext);
const parentPreviousScene = React.useContext(PreviousSceneContext); const parentPreviousScene = React.useContext(PreviousSceneContext);
return ( return (
@@ -66,11 +64,8 @@ export default function HeaderContainer({
return null; return null;
} }
const { const { header, headerShown = true, headerTransparent } =
header, scene.descriptor.options || {};
headerShown = isParentHeaderShown === false,
headerTransparent,
} = scene.descriptor.options || {};
if (!headerShown) { if (!headerShown) {
return null; return null;
@@ -85,11 +80,10 @@ export default function HeaderContainer({
const previousScene = self[i - 1]; const previousScene = self[i - 1];
const nextScene = self[i + 1]; const nextScene = self[i + 1];
const { const { headerShown: previousHeaderShown = true } =
headerShown: previousHeaderShown = isParentHeaderShown === false, previousScene?.descriptor.options || {};
} = previousScene?.descriptor.options || {};
const { headerShown: nextHeaderShown = isParentHeaderShown === false } = const { headerShown: nextHeaderShown = true } =
nextScene?.descriptor.options || {}; nextScene?.descriptor.options || {};
const isHeaderStatic = const isHeaderStatic =

View File

@@ -447,10 +447,7 @@ export default class CardStack extends React.Component<Props, State> {
? this.state.scenes.slice(-2).some((scene) => { ? this.state.scenes.slice(-2).some((scene) => {
const { descriptor } = scene; const { descriptor } = scene;
const options = descriptor ? descriptor.options : {}; const options = descriptor ? descriptor.options : {};
const { const { headerTransparent, headerShown = true } = options;
headerTransparent,
headerShown = isParentHeaderShown === false,
} = options;
if (headerTransparent || headerShown === false) { if (headerTransparent || headerShown === false) {
return true; return true;
@@ -542,7 +539,7 @@ export default class CardStack extends React.Component<Props, State> {
const { const {
safeAreaInsets, safeAreaInsets,
headerShown = isParentHeaderShown === false, headerShown = true,
headerTransparent, headerTransparent,
cardShadowEnabled, cardShadowEnabled,
cardOverlayEnabled, cardOverlayEnabled,