Clear Auth History Stack With 'react-router-dom'

I don’t know how to clear the auth history stack, but it is possible to disable the swipe back gesture on specific pages.

Here is the code I use for that (original idea here):

useGestureDisableSwipeBack.ts

import { useEffect } from 'react';
import { createGesture } from '@ionic/react';

// https://forum.ionicframework.com/t/how-to-disable-swipe-to-go-back-gesture-on-one-page-only-ionic-v5-react/196795/4
const useGestureDisableSwipeBack = (): void => {
  useEffect(() => {
    const pageSelector = document.querySelector('my-example-selector');
    if (pageSelector) {
      const gesture = createGesture({
        el: pageSelector,
        threshold: 0,
        gestureName: 'disable-swipe-back',
        gesturePriority: 40.5, // Priority of swipe to go back is 40.
        // onMove: (event) => console.log(event),
      });
      gesture.enable(true);
    }
    return () => {
      // TODO: Destroy gesture.
      // console.log('gesture clear placeholder');
      // gesture.destroy;
    };
  }, []);
};

export default useGestureDisableSwipeBack;
1 Like