From 8dc2e23927a6f61d9dc0405b854e0fc1e158d613 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Sat, 5 Oct 2024 22:13:03 +0530 Subject: Disable the default back button behavior --- App.tsx | 10 ++++++++-- android/app/src/main/AndroidManifest.xml | 2 +- src/components/Favorites.tsx | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/App.tsx b/App.tsx index 76ea9f1..08886a0 100644 --- a/App.tsx +++ b/App.tsx @@ -1,10 +1,16 @@ -import React, {Suspense} from 'react'; -import {SafeAreaView, View} from 'react-native'; +import React, {Suspense, useEffect} from 'react'; +import {BackHandler, SafeAreaView, View} from 'react-native'; import {GestureHandlerRootView} from 'react-native-gesture-handler'; import {AppView} from './src/AppView'; import {Provider as JotaiProvider} from 'jotai'; const App: React.FC = () => { + // Disable back button + useEffect(() => { + const sub = BackHandler.addEventListener('hardwareBackPress', () => true); + return () => sub.remove(); + }, []); + return ( }> diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 9bae7a2..66ed10a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -8,7 +8,7 @@ android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" - android:allowBackup="false" + android:allowBackup="true" android:theme="@style/AppTheme"> = (_) => { disabled={isActive} hitSlop={10} className="pr-2 py-3"> - + -- cgit v1.3.1