在我的场景中,我试图在单个文件中使用android back handler类。如何从多个类文件访问此文件,而不是复制它们。
我的下面的代码
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;
}
}
}
如何从其他多个班级文件屏幕访问?
export default class screenone extends Component {
// how to access here?
}