Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BackController extends Component {
- static propTypes = {
- onBack: PropTypes.func
- }
- constructor (props) {
- super(props)
- this.handleBack = this.handleBack.bind(this)
- }
- componentDidMount () {
- BackHandler.addEventListener('hardwareBackPress', this.handleBack)
- }
- componentWillUnmount () {
- BackHandler.removeEventListener('hardwareBackPress', this.handleBack)
- }
- handleBack () {
- if (typeof this.props.onBack === 'function') {
- this.props.onBack()
- }
- }
- render () {
- return null
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement