Make Hashrouter auto switch inline

This commit is contained in:
Saahil dutta 2024-07-26 14:45:33 -04:00
parent 87c4f48258
commit 372f16b010
3 changed files with 13 additions and 30 deletions

View file

@ -1,25 +0,0 @@
let interId:any = null
function hashEvent() {
window.location.reload() // ;-;
}
export function startEvent() {
if ("onhashchange" in window) {
window.addEventListener('hashchange', hashEvent)
}
else {
//@ts-ignore
var prevHash = window.location.hash;
//@ts-ignore
interId = window.setInterval(function () {
if (window.location.hash != prevHash) {
hashEvent()
}
}, 100);
}
}
export function stopEvent() {
if(interId) clearInterval(interId)
window.removeEventListener('hashchange', hashEvent)
}