fix: fix false warning due to change in Object.assign in metro preset

#8584
This commit is contained in:
Satyajit Sahoo
2020-07-22 03:06:55 +02:00
parent 7c2b28ae1e
commit 5e358b3aad
4 changed files with 20 additions and 7 deletions

View File

@@ -82,7 +82,6 @@ const ArticleScreen: CompatScreenType<StackNavigationProp<
NestedStackParams,
'Article'
>> = ({ navigation }) => {
navigation.dangerouslyGetParent();
return (
<ScrollView>
<View style={styles.buttons}>

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.2.2](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.2.1...@react-navigation/compat@5.2.2) (2020-07-22)
### Bug Fixes
* fix false warning due to change in Object.assign in metro preset ([240a706](https://github.com/react-navigation/react-navigation/commit/240a706a56220b63d603a52407a738c2872349dd)), closes [#8584](https://github.com/react-navigation/react-navigation/issues/8584)
## [5.2.1](https://github.com/react-navigation/react-navigation/compare/@react-navigation/compat@5.2.0...@react-navigation/compat@5.2.1) (2020-07-19)
**Note:** Version bump only for package @react-navigation/compat

View File

@@ -1,7 +1,7 @@
{
"name": "@react-navigation/compat",
"description": "Compatibility layer to write navigator definitions in static configuration format",
"version": "5.2.1",
"version": "5.2.2",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -143,9 +143,12 @@ export default function createCompatNavigationProp<
}
},
state: {
...state,
// @ts-expect-error: these properties may actually exist
key: state.key,
// @ts-expect-error
routeName: state.name,
// @ts-expect-error
params: state.params ?? {},
get index() {
// @ts-expect-error
if (state.index !== undefined) {
@@ -154,11 +157,11 @@ export default function createCompatNavigationProp<
}
console.warn(
"Accessing child navigation state for a route is not safe and won't work correctly."
"Looks like you are using 'navigation.state.index' in your code. Accessing child navigation state for a route is not safe and won't work correctly. You should refactor it not to access the 'index' property in the child navigation state."
);
// @ts-expect-error
return state.state ? state.state.index : undefined;
return state.state?.index;
},
get routes() {
// @ts-expect-error
@@ -168,11 +171,11 @@ export default function createCompatNavigationProp<
}
console.warn(
"Accessing child navigation state for a route is not safe and won't work correctly."
"Looks like you are using 'navigation.state.routes' in your code. Accessing child navigation state for a route is not safe and won't work correctly. You should refactor it not to access the 'routes' property in the child navigation state."
);
// @ts-expect-error
return state.state ? state.state.routes : undefined;
return state.state?.routes;
},
},
getParam<T extends keyof ParamList>(