In my scenario, I am trying to create global class for android back button handler and reuse it in multiple screen class files. How to do it? I tried below code but I dont know how to access common class from other classes.
My Code Below (Androidhandler.tsx)
export default class hardware extends Component { constructor(props) { super(props); this.BackButton = this.BackButton.bind(this); } componentWillMount() { BackHandler.addEventListener'BackPress',this.BackButton); } componentWillUnmount() { BackHandler.removeEventListener('BackPress',this.BackButton); } BackButton() { if(this.props.navigation){ this.props.navigation.goBack(null); return true; } }}