feat(v6): remove deprecated public API#4926
Conversation
|
The mobile version of example app from this branch is ready! You can see it here. |
96603d4 to
d51258f
Compare
- Delete src/deprecated.ts and all MD3*/DefaultTheme/useAppTheme re-exports - Remove createMaterialBottomTabNavigator and entire src/react-navigation/ directory - Remove theme.mode field from Theme type and DarkTheme definition - Remove ThemeBase type - Remove deprecated component props: FAB.small, Button.color, BottomNavigation BaseRoute.color - Remove Card adaptive dark mode logic (tonal surfaces handle dark theme in MD3) - Update example app and docs to use canonical names (Palette, LightTheme, DarkTheme) - Rename internal useAppTheme to _useTheme to avoid confusion with removed public symbol
469ac47 to
cf203b2
Compare
|
Hey @adrcotfas, thank you for your pull request 🤗. The documentation from this branch can be viewed here. |
| return _useTheme<T>(overrides); | ||
| } | ||
|
|
||
| export const useInternalTheme = ( | ||
| themeOverrides: $DeepPartial<Theme> | undefined | ||
| ) => useAppTheme<Theme>(themeOverrides); | ||
| ) => _useTheme<Theme>(themeOverrides); |
There was a problem hiding this comment.
Normally we don't use _ prefix for functions, only for class properties to signify they are internal to class as they are accessible by anyone with access to the class instance. For functions already scoped to module/other functions, it's an unnecessary signal.
| ); | ||
| const computedElevation = | ||
| dark && isAdaptiveMode ? elevationDarkAdaptive : elevation; | ||
| const computedElevation = elevation; |
There was a problem hiding this comment.
Guess we can remove computedElevation and use elevation directly? Otherwise, it's confusing since nothing is computed.
| import { useTheme, type Theme } from 'react-native-paper'; | ||
|
|
||
| export const useExampleTheme = () => useTheme<MD3Theme>(); | ||
| export const useExampleTheme = () => useTheme<Theme>(); |
There was a problem hiding this comment.
What does this hook do? Seems like nothing 🤔
| The `createMaterialBottomTabNavigator` has been deprecated as of `[email protected]`. Instead, use `@react-navigation/bottom-tabs` version `7.x` or later, combined with `BottomNavigation.Bar` to achieve a Material Design look. | ||
|
|
||
| For implementation details, see the [dedicated example](https://callstack.github.io/react-native-paper/docs/components/BottomNavigation/BottomNavigationBar#with-react-navigation). | ||
| `createMaterialBottomTabNavigator` was deprecated in `[email protected]` and removed in `[email protected]`. Use [`@react-navigation/bottom-tabs`](https://reactnavigation.org/docs/bottom-tab-navigator) (v7+) with [`BottomNavigation.Bar`](https://callstack.github.io/react-native-paper/docs/components/BottomNavigation/BottomNavigationBar) instead. |
There was a problem hiding this comment.
There's already instructions for React Navigation belo, and this will be in the upgrade guide, so I'd remove it from here.
|
|
||
| :::info | ||
| To use this navigator, ensure that you have [`@react-navigation/native` and its dependencies (follow this guide)](https://reactnavigation.org/docs/getting-started): | ||
| Install [`@react-navigation/native`](https://reactnavigation.org/docs/getting-started) and [`@react-navigation/bottom-tabs@^7`](https://reactnavigation.org/docs/bottom-tab-navigator) first. |
There was a problem hiding this comment.
Let's remove ^7. This guide will also work on 8.x and 6.x (tho no animation on 6.x).
| tabBar={({ navigation, state, descriptors, insets }) => ( | ||
| <BottomNavigation.Bar | ||
| navigationState={state} | ||
| safeAreaInsets={insets} |
There was a problem hiding this comment.
For upcoming React Navigation 8 compatibility, let's remove insets argument.
Add const insets = useSafeAreaInsets() from react-native-safe-area-context in the MyTabs component and pass insets from there (unless it's already handled by default in BottomNavigation.Bar).
| options={{ | ||
| tabBarLabel: 'Home', | ||
| tabBarIcon: ({ color }) => ( | ||
| <MaterialDesignIcons name="home" color={color} size={26} /> |
There was a problem hiding this comment.
Is this change correct? What are we using in other places?
Also, iirc upcoming Expo SDK no longer needs @expo/vector-icons.
| ## Migration | ||
|
|
||
| | Old (removed) | New | | ||
| |---|---| | ||
| | `createMaterialBottomTabNavigator()` | `createBottomTabNavigator()` from `@react-navigation/bottom-tabs` | | ||
| | `<Tab.Navigator activeColor inactiveColor barStyle shifting labeled theme>` | Pass the same props to `<BottomNavigation.Bar>` inside `tabBar` | | ||
| | `options.tabBarIcon` / `tabBarLabel` / `tabBarBadge` | Same names; read via `descriptors[route.key].options` in `renderIcon` / `getLabelText` | | ||
| | `options.tabBarColor` (theme v2) | Removed. MD3 uses tonal surface colors. | | ||
| | `navigation.jumpTo(name, params)` | Same. Provided by `@react-navigation/bottom-tabs`. | | ||
| | `tabPress` event | Same. Emitted by `@react-navigation/bottom-tabs`. | |
There was a problem hiding this comment.
I don't think we need migration in individual guides. We need to have a central guide for migrating to v6 that mentions all breaking changes.
Motivation
Related issue
See https://www.notion.so/callstack/React-Native-Paper-Foundation-for-MD3-Expressive-34c5d027c0f880edba3df107cd35946f?source=copy_link
Merge order:
Test plan
yarn typescript-- no new type errorsyarn test-- all tests pass