mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-13 17:47:39 +01:00
c3201cf632
This reverts commit 3c19438f1a9f6db9a06dc3b48bd06d062befe0b8.
16 lines
401 B
TypeScript
16 lines
401 B
TypeScript
// This is unsafe and can be not chained as `popstate` event is asynchronous
|
|
|
|
export default function useHistoryBack(handler: NoneToVoidFunction) {
|
|
function handlePopState() {
|
|
handler();
|
|
}
|
|
|
|
window.addEventListener('popstate', handlePopState);
|
|
window.history.pushState({}, '');
|
|
|
|
return () => {
|
|
window.removeEventListener('popstate', handlePopState);
|
|
window.history.back();
|
|
};
|
|
}
|