I want to handle the back button in my React Native application. I know that can use addEventListener in componentdidmount and componentWillUnmount to handle the back button.
My problem is, the page still exists in stack navigation, so on the other page I have the EventListener, but I want the EventListener on only one page.
The following example code from How to exit React Native app on back button pressed does not solve the problem.