From 1b29a0a6bcfa4d609fbb9eab9b3a530e67a01449 Mon Sep 17 00:00:00 2001 From: loup Date: Tue, 3 Nov 2026 00:27:02 +0100 Subject: [PATCH] fix(mobile): move to Expo SDK 58 and React Native 0.88 Driven from Expo's official SDK 58 matrix, applied to the root catalog rather than with `expo install --fix`: every one of the 349 root dependencies is a `catalog:` reference, so letting the CLI pin versions in apps/mobile would have written them twice and broken a convention the repo applies without exception. `expo install --check` and `expo-doctor` then confirm the result (20/20). React and react-dom move to 19.3.0 for the whole monorepo instead of diverging mobile from web, notify and ui -- keeping one React version is what the catalog is for. Router migrations, all from the official SDK 57 to 58 guide: - `initialRouteName` is removed; eight layouts now export `unstable_settings.anchor`. The shared `(home,search,collection,feed)` layout gets one anchor per segment, and its former branch on `user` is dropped: `Stack.Protected` already decides whether `feed` and `collection/(tabs)` are registered at all, so there is nothing left to anchor to. - `Screen` no longer accepts `initialParams`; the two screens under `user/[username]/(follow)` already read `username` from the URL. - The four hand-rolled top-tab navigators drop `createMaterialTopTabNavigator` plus `withLayoutContext` for the ready-made `TopTabs`. - `MaterialTopTabBarProps` replaces `navigation` with `emitter` and `navigateToTab`. React Native 0.88 ships the Strict TypeScript API as the default, which accounts for 52 of the 62 type errors the upgrade surfaced. Those are deferred behind the `react-native-legacy-deep-imports` condition in the mobile tsconfig, for two reasons: an SDK upgrade and a repo-wide type-API migration are separate changes, and one of the 52 is not ours to fix -- @react-native-segmented-control declares `Constructor`, and `NativeMethods` no longer exists in 0.88's types, with 2.5.7 the last published version. `types_DEPRECATED` will go away in a later React Native, so this is explicit debt, not a resolution. Nitro was pinned to 0.35.10 by its own catalog range: `^0.35.0` on a 0.x version means `>=0.35.0 <0.36.0`. Its C++ compiles against React Native's internals, so it failed to install its JSI bindings on 0.88 and took MMKV down with it. Both now match what the other SDK 58 apps in this org run on 0.88. The remaining fixes are mechanical: `StyleSheet.NamedStyles` and `ViewToken` are gone from the type surface, 17 `onPress={form.handleSubmit(x)}` handlers no longer satisfy the stricter press signature, and `AndroidImportance` is imported by name so `import/namespace` stops failing to follow expo-notifications' ESM re-export chain. Requires a native rebuild: `expo prebuild --clean` then a device build. The fingerprint changes, so the next release takes the native build path rather than an OTA. --- apps/mobile/app.config.ts | 1 - .../(home,search,collection,feed)/_layout.tsx | 28 +- .../collection/(tabs)/_layout.tsx | 30 +- .../feed/_layout.tsx | 31 +- .../search/_layout.tsx | 6 +- .../user/[username]/(follow)/_layout.tsx | 32 +- apps/mobile/src/app/(tabs)/_layout.tsx | 2 +- apps/mobile/src/app/_layout.tsx | 6 +- apps/mobile/src/app/auth/(main)/_layout.tsx | 5 +- apps/mobile/src/app/auth/(main)/login/otp.tsx | 4 +- apps/mobile/src/app/auth/(main)/signup.tsx | 2 +- .../src/app/auth/(password)/_layout.tsx | 5 +- .../app/playlist/[playlist_id]/edit/index.tsx | 4 +- .../src/app/playlist/add/[type]/[id].tsx | 2 +- apps/mobile/src/app/reco/send/[type]/[id].tsx | 2 +- apps/mobile/src/app/settings/account.tsx | 4 +- apps/mobile/src/app/settings/appearance.tsx | 4 +- .../src/app/settings/data/(main)/_layout.tsx | 32 +- apps/mobile/src/app/settings/profile.tsx | 4 +- apps/mobile/src/app/settings/security.tsx | 4 +- .../sheets/BottomSheetBookmarkComment.tsx | 2 +- .../sheets/BottomSheetComment.tsx | 2 +- .../ui/segmented-control-tabbar.tsx | 7 +- apps/mobile/src/hooks/useStyles.tsx | 11 +- .../src/providers/NotificationsProvider.tsx | 3 +- .../screens/onboarding/OnboardingScreen.tsx | 8 +- apps/mobile/src/widgets/BookmarksWidget.tsx | 3 +- apps/mobile/src/widgets/RecosWidget.tsx | 3 +- apps/mobile/tsconfig.json | 1 + bun.lock | 1380 +++++++++-------- package.json | 136 +- 31 files changed, 899 insertions(+), 865 deletions(-) diff --git a/apps/mobile/app.config.ts b/apps/mobile/app.config.ts index 2d24f120..e93a4d1f 100644 --- a/apps/mobile/app.config.ts +++ b/apps/mobile/app.config.ts @@ -124,7 +124,6 @@ export default ({ config }: ConfigContext): ExpoConfig => ({ ios: { deploymentTarget: '16.4', useFrameworks: 'static', - enableSceneSupport: true, }, }, ], diff --git a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/_layout.tsx b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/_layout.tsx index 7c1ae3f2..25a225d8 100644 --- a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/_layout.tsx +++ b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/_layout.tsx @@ -2,30 +2,24 @@ import { useAuth } from '../../../providers/AuthProvider'; import { useTheme } from '../../../providers/ThemeProvider'; import { Stack } from 'expo-router'; import { upperFirst } from 'lodash'; -import { useMemo } from 'react'; import { useTranslations } from 'use-intl'; +export const unstable_settings = { + // One anchor per segment of the shared route. The former value also branched on `user`, + // which `Stack.Protected` below now decides on its own: an unauthenticated visitor never + // gets `feed` or `collection/(tabs)` registered, so there is nothing to anchor to. + anchor: 'index', + search: { anchor: 'search' }, + collection: { anchor: 'collection/(tabs)' }, + feed: { anchor: 'feed' }, +}; + const AppLayout = ({ segment }: { segment: string }) => { const { defaultScreenOptions } = useTheme(); const t = useTranslations(); const { user } = useAuth(); - const initialRouteName = useMemo(() => { - switch (segment) { - case '(search)': - return 'search'; - case '(feed)': - // 'feed' is only registered in the Stack when guard={!!user} passes (see below). - return user ? 'feed' : 'index'; - case '(collection)': - // 'collection/(tabs)' is only registered in the Stack when guard={!!user} passes (see below). - return user ? 'collection/(tabs)' : 'index'; - default: - return 'index'; - } - }, [segment, user]); - return ( - + , - MaterialTopTabNavigationEventMap ->(Tab.Navigator); - const CollectionLayout = () => { const t = useTranslations(); const router = useRouter(); @@ -136,17 +122,15 @@ const CollectionLayout = () => { ], }} /> - } - > - - }> + + - + ); }; diff --git a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/feed/_layout.tsx b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/feed/_layout.tsx index b944d460..8b01701a 100644 --- a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/feed/_layout.tsx +++ b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/feed/_layout.tsx @@ -1,40 +1,25 @@ -import { - createMaterialTopTabNavigator, - MaterialTopTabBarProps, - MaterialTopTabNavigationEventMap, - MaterialTopTabNavigationOptions, -} from 'expo-router/js-top-tabs'; -import { ParamListBase, TabNavigationState } from 'expo-router/react-navigation'; -import { withLayoutContext } from 'expo-router'; +import { MaterialTopTabBarProps, TopTabs } from 'expo-router/js-top-tabs'; import { upperFirst } from 'lodash'; import { useTranslations } from 'use-intl'; import { SegmentedControlTabBar } from '../../../../components/ui/segmented-control-tabbar'; -const Tab = createMaterialTopTabNavigator(); - -const MaterialTopTabs = withLayoutContext< - MaterialTopTabNavigationOptions, - typeof Tab.Navigator, - TabNavigationState, - MaterialTopTabNavigationEventMap ->(Tab.Navigator); +export const unstable_settings = { + anchor: 'index', +}; const FeedLayout = () => { const t = useTranslations(); return ( - } - > - }> + - - + ); }; diff --git a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/search/_layout.tsx b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/search/_layout.tsx index b9a7cd08..60e89462 100644 --- a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/search/_layout.tsx +++ b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/search/_layout.tsx @@ -6,6 +6,10 @@ import { upperFirst } from 'lodash'; import { useCallback, useEffect, useState } from 'react'; import { useTranslations } from 'use-intl'; +export const unstable_settings = { + anchor: '(tabs)', +}; + const SearchLayout = () => { const t = useTranslations(); const pathname = usePathname(); @@ -79,7 +83,7 @@ const SearchLayout = () => { ...headerSearchBar, }} /> - + ); }; diff --git a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/user/[username]/(follow)/_layout.tsx b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/user/[username]/(follow)/_layout.tsx index a0610d6b..95505029 100644 --- a/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/user/[username]/(follow)/_layout.tsx +++ b/apps/mobile/src/app/(tabs)/(home,search,collection,feed)/user/[username]/(follow)/_layout.tsx @@ -1,27 +1,18 @@ import { View } from '../../../../../../components/ui/view'; import tw from '../../../../../../lib/tw'; import { useTheme } from '../../../../../../providers/ThemeProvider'; -import { - createMaterialTopTabNavigator, - MaterialTopTabNavigationEventMap, - MaterialTopTabNavigationOptions, -} from 'expo-router/js-top-tabs'; -import { HeaderTitle, ParamListBase, TabNavigationState } from 'expo-router/react-navigation'; -import { Stack, useLocalSearchParams, withLayoutContext } from 'expo-router'; +import { TopTabs } from 'expo-router/js-top-tabs'; +import { HeaderTitle } from 'expo-router/react-navigation'; +import { Stack, useLocalSearchParams } from 'expo-router'; import { upperFirst } from 'lodash'; import { useTranslations } from 'use-intl'; import { Icons } from '../../../../../../constants/Icons'; import { useQuery } from '@tanstack/react-query'; import { userByUsernameOptions } from '@libs/query-client'; -const Tab = createMaterialTopTabNavigator(); - -const MaterialTopTabs = withLayoutContext< - MaterialTopTabNavigationOptions, - typeof Tab.Navigator, - TabNavigationState, - MaterialTopTabNavigationEventMap ->(Tab.Navigator); +export const unstable_settings = { + anchor: 'followers', +}; const ProfileFollowLayout = () => { const { username } = useLocalSearchParams<{ username: string }>(); @@ -42,8 +33,7 @@ const ProfileFollowLayout = () => { headerBackButtonDisplayMode: 'minimal', }} /> - { }, }} > - - - + ); }; diff --git a/apps/mobile/src/app/(tabs)/_layout.tsx b/apps/mobile/src/app/(tabs)/_layout.tsx index 152d301f..cd1c271f 100644 --- a/apps/mobile/src/app/(tabs)/_layout.tsx +++ b/apps/mobile/src/app/(tabs)/_layout.tsx @@ -4,7 +4,7 @@ import { useTheme } from '../../providers/ThemeProvider'; import { useTranslations } from 'use-intl'; import { upperFirst } from 'lodash'; import { useAppGates } from '../../hooks/gates/useAppGates'; -import { NativeTabs } from 'expo-router/unstable-native-tabs'; +import { NativeTabs } from 'expo-router/native-tabs'; import { isIOS } from '../../platform/detection'; const TabsLayout = () => { diff --git a/apps/mobile/src/app/_layout.tsx b/apps/mobile/src/app/_layout.tsx index d4741961..41474f97 100644 --- a/apps/mobile/src/app/_layout.tsx +++ b/apps/mobile/src/app/_layout.tsx @@ -21,6 +21,10 @@ import { useTranslations } from 'use-intl'; import { Platform } from 'react-native'; import { osName } from 'expo-device'; +export const unstable_settings = { + anchor: '(tabs)', +}; + export { ErrorBoundary } from '../providers/ErrorBoundaryProvider'; enableScreens(true); @@ -38,7 +42,7 @@ const RootLayoutNav = () => { const { defaultScreenOptions, isLiquidGlassAvailable } = useTheme(); useHomeWidgetsSync(); return ( - + { const t = useTranslations(); const { defaultScreenOptions } = useTheme(); return ( { {/* SUBMIT BUTTON */} diff --git a/apps/mobile/src/app/auth/(main)/signup.tsx b/apps/mobile/src/app/auth/(main)/signup.tsx index 5e367925..72a4d58e 100644 --- a/apps/mobile/src/app/auth/(main)/signup.tsx +++ b/apps/mobile/src/app/auth/(main)/signup.tsx @@ -411,7 +411,7 @@ const SignupScreen = () => { {/* SUBMIT BUTTON */} diff --git a/apps/mobile/src/app/reco/send/[type]/[id].tsx b/apps/mobile/src/app/reco/send/[type]/[id].tsx index 1d0fb519..9f121478 100644 --- a/apps/mobile/src/app/reco/send/[type]/[id].tsx +++ b/apps/mobile/src/app/reco/send/[type]/[id].tsx @@ -307,7 +307,7 @@ const RecoSend = () => { disabled={!canSave || isSendingReco} variant="outline" size="lg" - onPress={form.handleSubmit(handleSubmit)} + onPress={() => void form.handleSubmit(handleSubmit)()} > {upperFirst(t('common.messages.send'))} diff --git a/apps/mobile/src/app/settings/account.tsx b/apps/mobile/src/app/settings/account.tsx index db9f781a..9be98f08 100644 --- a/apps/mobile/src/app/settings/account.tsx +++ b/apps/mobile/src/app/settings/account.tsx @@ -217,7 +217,7 @@ const SettingsAccountScreen = () => { variant="ghost" size="fit" loading={isLoading} - onPress={form.handleSubmit(handleOnSubmit)} + onPress={() => void form.handleSubmit(handleOnSubmit)()} disabled={!hasUnsavedChanges || !form.formState.isValid || isLoading} > {upperFirst(t('common.messages.save'))} @@ -227,7 +227,7 @@ const SettingsAccountScreen = () => { { type: 'button', label: upperFirst(t('common.messages.save')), - onPress: form.handleSubmit(handleOnSubmit), + onPress: () => void form.handleSubmit(handleOnSubmit)(), tintColor: props.tintColor, disabled: !hasUnsavedChanges || !form.formState.isValid || isLoading, icon: { diff --git a/apps/mobile/src/app/settings/appearance.tsx b/apps/mobile/src/app/settings/appearance.tsx index 5c9ad64e..d97844b8 100644 --- a/apps/mobile/src/app/settings/appearance.tsx +++ b/apps/mobile/src/app/settings/appearance.tsx @@ -91,7 +91,7 @@ const SettingsAppearanceScreen = () => { variant="ghost" size="fit" loading={isLoading} - onPress={form.handleSubmit(handleSubmit)} + onPress={() => void form.handleSubmit(handleSubmit)()} disabled={!form.formState.isDirty || !form.formState.isValid || isLoading} > {upperFirst(t('common.messages.save'))} @@ -101,7 +101,7 @@ const SettingsAppearanceScreen = () => { { type: 'button', label: upperFirst(t('common.messages.save')), - onPress: form.handleSubmit(handleSubmit), + onPress: () => void form.handleSubmit(handleSubmit)(), tintColor: props.tintColor, disabled: !form.formState.isDirty || !form.formState.isValid || isLoading, icon: { diff --git a/apps/mobile/src/app/settings/data/(main)/_layout.tsx b/apps/mobile/src/app/settings/data/(main)/_layout.tsx index 1ce1656a..bbfdf3fb 100644 --- a/apps/mobile/src/app/settings/data/(main)/_layout.tsx +++ b/apps/mobile/src/app/settings/data/(main)/_layout.tsx @@ -1,11 +1,5 @@ -import { - createMaterialTopTabNavigator, - MaterialTopTabBarProps, - MaterialTopTabNavigationEventMap, - MaterialTopTabNavigationOptions, -} from 'expo-router/js-top-tabs'; -import { ParamListBase, TabNavigationState } from 'expo-router/react-navigation'; -import { Stack, usePathname, useRouter, withLayoutContext } from 'expo-router'; +import { MaterialTopTabBarProps, TopTabs } from 'expo-router/js-top-tabs'; +import { Stack, usePathname, useRouter } from 'expo-router'; import { upperFirst } from 'lodash'; import { useTranslations } from 'use-intl'; import { SegmentedControlTabBar } from '../../../../components/ui/segmented-control-tabbar'; @@ -14,14 +8,9 @@ import { Icons } from '../../../../constants/Icons'; import tw from '../../../../lib/tw'; import { useMemo } from 'react'; -const Tab = createMaterialTopTabNavigator(); - -const MaterialTopTabs = withLayoutContext< - MaterialTopTabNavigationOptions, - typeof Tab.Navigator, - TabNavigationState, - MaterialTopTabNavigationEventMap ->(Tab.Navigator); +export const unstable_settings = { + anchor: 'imports', +}; const SettingsDataLayout = ({ segment }: { segment: string }) => { const t = useTranslations(); @@ -67,19 +56,16 @@ const SettingsDataLayout = ({ segment }: { segment: string }) => { : [], }} /> - } - > - }> + - - + ); }; diff --git a/apps/mobile/src/app/settings/profile.tsx b/apps/mobile/src/app/settings/profile.tsx index 094a87ca..5035e436 100644 --- a/apps/mobile/src/app/settings/profile.tsx +++ b/apps/mobile/src/app/settings/profile.tsx @@ -236,7 +236,7 @@ const SettingsProfileScreen = () => { variant="ghost" size="fit" loading={isPending} - onPress={form.handleSubmit(handleSubmit)} + onPress={() => void form.handleSubmit(handleSubmit)()} disabled={!canSave || isPending} > {upperFirst(t('common.messages.save'))} @@ -246,7 +246,7 @@ const SettingsProfileScreen = () => { { type: 'button', label: upperFirst(t('common.messages.save')), - onPress: form.handleSubmit(handleSubmit), + onPress: () => void form.handleSubmit(handleSubmit)(), tintColor: props.tintColor, disabled: !canSave || isPending, icon: { diff --git a/apps/mobile/src/app/settings/security.tsx b/apps/mobile/src/app/settings/security.tsx index 9f471bff..8e1df2ae 100644 --- a/apps/mobile/src/app/settings/security.tsx +++ b/apps/mobile/src/app/settings/security.tsx @@ -120,7 +120,7 @@ const SettingsSecurityScreen = () => { variant="ghost" size="fit" loading={isLoading} - onPress={form.handleSubmit(handleSubmit)} + onPress={() => void form.handleSubmit(handleSubmit)()} disabled={!form.formState.isValid || isLoading} > {upperFirst(t('common.messages.save'))} @@ -130,7 +130,7 @@ const SettingsSecurityScreen = () => { { type: 'button', label: upperFirst(t('common.messages.save')), - onPress: form.handleSubmit(handleSubmit), + onPress: () => void form.handleSubmit(handleSubmit)(), tintColor: props.tintColor, disabled: !form.formState.isValid || isLoading, icon: { diff --git a/apps/mobile/src/components/bottom-sheets/sheets/BottomSheetBookmarkComment.tsx b/apps/mobile/src/components/bottom-sheets/sheets/BottomSheetBookmarkComment.tsx index f8b8aba3..8b3367bf 100644 --- a/apps/mobile/src/components/bottom-sheets/sheets/BottomSheetBookmarkComment.tsx +++ b/apps/mobile/src/components/bottom-sheets/sheets/BottomSheetBookmarkComment.tsx @@ -136,7 +136,7 @@ export const BottomSheetBookmarkComment = forwardRef< />