'Why the Android back button not working when react-native-paper Dialog is visible?

I use react-native-paper non-dismissable Dialog component, and react navigation V5 for navigation, for some reason when the dialog is visible then the Android back button is not working and I have to close the Dialog to go back.

I tried to also use BackHandler.addEventListener but my handler is not being called at all.

How can I solve it?

EDIT: changed 'now' in title to 'not'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source