From 583fac69388f53555c6ac9215ad7e2447f5d3825 Mon Sep 17 00:00:00 2001 From: Gauvain Date: Thu, 4 Jun 2026 00:16:40 +0200 Subject: [PATCH] fix(settings): lazy-load clipboard so the Account screen opens without a native rebuild --- .../(tabs)/(home)/settings/account/page.tsx | 23 +++++++++++++------ translations/en.json | 3 ++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/app/(auth)/(tabs)/(home)/settings/account/page.tsx b/app/(auth)/(tabs)/(home)/settings/account/page.tsx index 6d439d9ef..56bd8a512 100644 --- a/app/(auth)/(tabs)/(home)/settings/account/page.tsx +++ b/app/(auth)/(tabs)/(home)/settings/account/page.tsx @@ -1,5 +1,4 @@ import * as Application from "expo-application"; -import { setStringAsync } from "expo-clipboard"; import { t } from "i18next"; import { useAtom } from "jotai"; import { useState } from "react"; @@ -18,6 +17,21 @@ export default function AccountPage() { const token = api?.accessToken ?? ""; const masked = token ? `•••• •••• •••• ${token.slice(-4)}` : ""; + const copyToken = async () => { + if (!token) return; + try { + // Lazy import: expo-clipboard is a native module. Importing it at module + // top crashes the screen on a dev client built before it was added; the + // dynamic import defers loading until the user taps copy. + const Clipboard = await import("expo-clipboard"); + await Clipboard.setStringAsync(token); + success(); + Alert.alert(t("home.settings.account.copied")); + } catch { + Alert.alert(t("home.settings.account.copy_unavailable")); + } + }; + return ( @@ -37,12 +51,7 @@ export default function AccountPage() { { - if (!token) return; - await setStringAsync(token); - success(); - Alert.alert(t("home.settings.account.copied")); - }} + onPress={copyToken} />