From d3adbc5f98131f2457ba41a80c16b355d9d3c84d Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 20 Apr 2020 11:47:11 +0500 Subject: [PATCH] fix backhandler --- apps/mobile/src/views/Editor/index.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js index fbbaa5741..ffe60d1b7 100755 --- a/apps/mobile/src/views/Editor/index.js +++ b/apps/mobile/src/views/Editor/index.js @@ -82,6 +82,12 @@ const Editor = ({noMenu}) => { const loadNote = async item => { //EditorWebView.current?.requestFocus(); editing.currentlyEditing = true; + if (!DDS.isTab) { + handleBack = BackHandler.addEventListener( + 'hardwareBackPress', + _onHardwareBackPress, + ); + } noMenu ? null : sideMenuRef.current?.setGestureEnabled(false); if (note && note.id) { dispatch({type: ACTIONS.NOTES}); @@ -450,21 +456,6 @@ const Editor = ({noMenu}) => { }; }, [noMenu]); - useEffect(() => { - if (!DDS.isTab) { - handleBack = BackHandler.addEventListener( - 'hardwareBackPress', - _onHardwareBackPress, - ); - } - return () => { - if (handleBack) { - handleBack.remove(); - handleBack = null; - } - }; - }, []); - const _onBackPress = async () => { editing.currentlyEditing = true; if (DDS.isTab) {