Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. class BackController extends Component {
  2. static propTypes = {
  3. onBack: PropTypes.func
  4. }
  5. constructor (props) {
  6. super(props)
  7. this.handleBack = this.handleBack.bind(this)
  8. }
  9. componentDidMount () {
  10. BackHandler.addEventListener('hardwareBackPress', this.handleBack)
  11. }
  12. componentWillUnmount () {
  13. BackHandler.removeEventListener('hardwareBackPress', this.handleBack)
  14. }
  15. handleBack () {
  16. if (typeof this.props.onBack === 'function') {
  17. this.props.onBack()
  18. }
  19. }
  20. render () {
  21. return null
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement