mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
24 lines
486 B
TypeScript
24 lines
486 B
TypeScript
import { useEffect } from 'react';
|
|
import { history } from '~/redux/store';
|
|
|
|
/**
|
|
* useBlockBackButton - blocks back navigation and calls {callback}
|
|
* @param callback
|
|
*/
|
|
export const useBlockBackButton = (callback?: () => void) => {
|
|
useEffect(
|
|
() =>
|
|
history.listen((newLocation, action) => {
|
|
if (action !== 'POP') {
|
|
return;
|
|
}
|
|
|
|
history.goForward();
|
|
|
|
if (callback) {
|
|
callback();
|
|
}
|
|
}),
|
|
[callback]
|
|
);
|
|
};
|