C
C
Coder3212018-07-24 20:57:32
JavaScript
Coder321, 2018-07-24 20:57:32

How to disable swipe back in a specific tab in react-navigation?

How to disable swipe back in a specific tab in react-navigation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2018-07-25
@lebonnet

touchstart remember coordinates and
touchend element compare coordinates if swipe back and tab was needed e.preventDefault();

R
Roman Aleksandrovich, 2018-07-25
@RomReed

in the documentation you can find a description of the implementation of the back function (onBackButtonPressAndroid) https://reactnavigation.org/docs/en/custom-android...
my function looks like this

onBackPress = () => {
    const { dispatch, nav } = this.props
    if (nav.index === 0) {
      return false
    }
    dispatch(NavigationActions.back())
    return true
  }

as you can see, I give the nav values ​​\u200b\u200bfrom the redux and perform a check. I think this is just the answer to your question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question