diff --git a/App/screens/DataUpload.tsx b/App/screens/DataUpload.tsx index 35784a3..bba9b3e 100644 --- a/App/screens/DataUpload.tsx +++ b/App/screens/DataUpload.tsx @@ -1,5 +1,6 @@ -import React from 'react'; -import {StyleSheet, View, Text} from 'react-native'; +import React, {useCallback} from 'react'; +import {StyleSheet, View, Text, BackHandler} from 'react-native'; +import {useFocusEffect} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; import {RootStackParamList} from 'App/App'; import Header from '../components/Header'; @@ -28,6 +29,18 @@ export const DataUpload: React.FC<{ }> = ({navigation}) => { const {t} = useTranslation(); + useFocusEffect( + useCallback(() => { + const onBackPress = (): boolean => { + navigation.navigate('Home'); + return true; + }; + BackHandler.addEventListener('hardwareBackPress', onBackPress); + return (): void => + BackHandler.removeEventListener('hardwareBackPress', onBackPress); + }, [navigation]), + ); + return (