From 8dc2e23927a6f61d9dc0405b854e0fc1e158d613 Mon Sep 17 00:00:00 2001
From: Akshay Nair <phenax5@gmail.com>
Date: Sat, 5 Oct 2024 22:13:03 +0530
Subject: Disable the default back button behavior

---
 App.tsx | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'App.tsx')

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 (
     <Suspense fallback={<View className="flex flex-1 bg-black" />}>
       <JotaiProvider>
-- 
cgit v1.3.1

