chore: add documentation links in deprecation messages

This commit is contained in:
Satyajit Sahoo
2021-07-27 13:00:23 +02:00
parent 5f4e124032
commit 504b26f3ae
5 changed files with 36 additions and 7 deletions

View File

@@ -63,6 +63,15 @@ function BottomTabNavigator({
],
});
(
Object.keys(defaultScreenOptions) as (keyof BottomTabNavigationOptions)[]
).forEach((key) => {
if (defaultScreenOptions[key] === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete defaultScreenOptions[key];
}
});
warnOnce(
tabBarOptions,
`Bottom Tab Navigator: 'tabBarOptions' is deprecated. Migrate the options to 'screenOptions' instead.\n\nPlace the following in 'screenOptions' in your code to keep current behavior:\n\n${JSON.stringify(
@@ -78,7 +87,7 @@ function BottomTabNavigator({
warnOnce(
true,
`Bottom Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.`
`Bottom Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/6.x/bottom-tab-navigator/#lazy for more details.`
);
}

View File

@@ -83,7 +83,7 @@ export default function useNavigationHelpers<
);
},
getParent: () => parentNavigationHelpers as any,
getState: getState,
getState,
} as NavigationHelpers<ParamListBase, EventMap> &
(NavigationProp<ParamListBase, string, any, any, any> | undefined) &
ActionHelpers;

View File

@@ -55,6 +55,15 @@ function DrawerNavigator({
gestureHandlerProps: drawerContentOptions.gestureHandlerProps,
});
(
Object.keys(defaultScreenOptions) as (keyof DrawerNavigationOptions)[]
).forEach((key) => {
if (defaultScreenOptions[key] === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete defaultScreenOptions[key];
}
});
warnOnce(
drawerContentOptions,
`Drawer Navigator: 'drawerContentOptions' is deprecated. Migrate the options to 'screenOptions' instead.\n\nPlace the following in 'screenOptions' in your code to keep current behavior:\n\n${JSON.stringify(
@@ -70,7 +79,7 @@ function DrawerNavigator({
warnOnce(
true,
`Drawer Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.`
`Drawer Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/6.x/drawer-navigator/#lazy for more details.`
);
}

View File

@@ -59,6 +59,17 @@ function MaterialTopTabNavigator({
tabBarStyle: tabBarOptions.style,
});
(
Object.keys(
defaultScreenOptions
) as (keyof MaterialTopTabNavigationOptions)[]
).forEach((key) => {
if (defaultScreenOptions[key] === undefined) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete defaultScreenOptions[key];
}
});
warnOnce(
tabBarOptions,
`Material Top Tab Navigator: 'tabBarOptions' is deprecated. Migrate the options to 'screenOptions' instead.\n\nPlace the following in 'screenOptions' in your code to keep current behavior:\n\n${JSON.stringify(
@@ -74,7 +85,7 @@ function MaterialTopTabNavigator({
warnOnce(
true,
`Material Top Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.`
`Material Top Tab Navigator: 'lazy' in props is deprecated. Move it to 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/6.x/material-top-tab-navigator#lazy for more details.`
);
}

View File

@@ -45,17 +45,17 @@ function StackNavigator({
warnOnce(
mode != null,
`Stack Navigator: 'mode="${mode}"' is deprecated. Use 'presentation: "${mode}"' in 'screenOptions' instead.`
`Stack Navigator: 'mode="${mode}"' is deprecated. Use 'presentation: "${mode}"' in 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/6.x/stack-navigator#presentation for more details.`
);
warnOnce(
headerMode === 'none',
`Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.`
`Stack Navigator: 'headerMode="none"' is deprecated. Use 'headerShown: false' in 'screenOptions' instead.\n\nSee https://reactnavigation.org/docs/6.x/stack-navigator/#headershown for more details.`
);
warnOnce(
headerMode != null && headerMode !== 'none',
`Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.`
`Stack Navigator: 'headerMode' is moved to 'options'. Moved it to 'screenOptions' to keep current behavior.\n\nSee https://reactnavigation.org/docs/6.x/stack-navigator/#headermode for more details.`
);
const { state, descriptors, navigation, NavigationContent } =