diff --git a/packages/docusaurus-theme-classic/src/nprogress.ts b/packages/docusaurus-theme-classic/src/nprogress.ts index 9db730401d2e..7e5103b98ef6 100644 --- a/packages/docusaurus-theme-classic/src/nprogress.ts +++ b/packages/docusaurus-theme-classic/src/nprogress.ts @@ -15,7 +15,7 @@ const delay = 200; const clientModule: ClientModule = { onRouteUpdate({location, previousLocation}) { - if (location.pathname !== previousLocation?.pathname) { + if (previousLocation && location.pathname !== previousLocation.pathname) { const progressBarTimeout = window.setTimeout(() => { nprogress.start(); }, delay);