In my scenario, I am trying to use android back handler class in single file. How to access this from multiple class files instead of duplicating.
my code below
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; } }}
How to access from multiple other class files screens?
export default class screenone extends Component { // how to access here?}