From 52c86e29b8f757d5894077bbb10e292a1669dbae Mon Sep 17 00:00:00 2001 From: zecka Date: Wed, 16 Oct 2024 14:49:52 +0200 Subject: [PATCH] fix: Disable loader on replace state to handle cached redirection (#17) --- src/AppProgressBar.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/AppProgressBar.tsx b/src/AppProgressBar.tsx index b462e81..0496af5 100644 --- a/src/AppProgressBar.tsx +++ b/src/AppProgressBar.tsx @@ -150,12 +150,16 @@ export const Next13ProgressBar = React.memo( const mutationObserver = new MutationObserver(handleMutation); mutationObserver.observe(document, { childList: true, subtree: true }); - window.history.pushState = new Proxy(window.history.pushState, { + const proxyStateChange = new Proxy(window.history.pushState, { apply: (target, thisArg, argArray: PushStateInput) => { stopProgress(); return target.apply(thisArg, argArray); }, }); + + window.history.pushState = proxyStateChange; + window.history.replaceState = proxyStateChange; + }, []); return styles;