Parth Pandya Parth Pandya - 4 months ago 233
iOS Question

How to disable back swipe gesture in react native navigator

I am developing one iOS application in react native. I have used Navigator component of react native. When I am pushing user from one screen to another then user can able to pop the screen by swipe on the left edge of the screen. I know how to disable it in native iOS code. However is there any way we can Stop that behavior in React-native app.

Thanks,

Answer

I solved it below way,

In React Project I have node_modules folder. There is code for Navigator component at this path,

/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js

In that file There is actions for Gestures on Navigations. By removing 'pop' gesture from there stops poping back when slide in from left edge of the screen.

Just replace below code,

var GESTURE_ACTIONS = [
  'pop',
  'jumpBack',
  'jumpForward',
];

with this code,

var GESTURE_ACTIONS = [
  'jumpBack',
  'jumpForward',
];
Comments