fix(rn) add backhandler on Prejoin screen

This commit is contained in:
Titus Moldovan 2022-06-20 14:40:34 +03:00 committed by tmoldovan8x8
parent c29e8bbdd1
commit d1c9720033
1 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import React, { useCallback, useLayoutEffect, useState } from 'react';
import React, { useCallback, useEffect, useLayoutEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Text, View, TouchableOpacity, TextInput, Platform } from 'react-native';
import { Text, View, TouchableOpacity, TextInput, Platform, BackHandler } from 'react-native';
import { useDispatch, useSelector } from 'react-redux';
import { appNavigate } from '../../app/actions.native';
@ -58,6 +58,7 @@ const Prejoin: ({ navigation }: Props) => JSX.Element = ({ navigation }: Props)
const goBack = useCallback(() => {
dispatch(appNavigate(undefined));
return true;
}, [ dispatch ]);
let contentWrapperStyles;
@ -93,6 +94,13 @@ const Prejoin: ({ navigation }: Props) => JSX.Element = ({ navigation }: Props)
);
}, []);
useEffect(() => {
BackHandler.addEventListener('hardwareBackPress', goBack);
return () => BackHandler.removeEventListener('hardwareBackPress', goBack)
}, [ ]);
useLayoutEffect(() => {
navigation.setOptions({
headerLeft