diff --git a/packages/docusaurus/src/client/App.tsx b/packages/docusaurus/src/client/App.tsx index cd203de487..abbf3aa9e6 100644 --- a/packages/docusaurus/src/client/App.tsx +++ b/packages/docusaurus/src/client/App.tsx @@ -23,7 +23,7 @@ function App(): JSX.Element { - + {renderRoutes(routes)} diff --git a/packages/docusaurus/src/client/PendingNavigation.tsx b/packages/docusaurus/src/client/PendingNavigation.tsx index 0af38d3543..42f4f11674 100644 --- a/packages/docusaurus/src/client/PendingNavigation.tsx +++ b/packages/docusaurus/src/client/PendingNavigation.tsx @@ -6,29 +6,30 @@ */ import React from 'react'; -import {Route, withRouter} from 'react-router-dom'; +import {Route, withRouter, RouteComponentProps} from 'react-router-dom'; import {RouteConfig} from 'react-router-config'; import nprogress from 'nprogress'; import clientLifecyclesDispatcher from './client-lifecycles-dispatcher'; import preload from './preload'; import normalizeLocation from './normalizeLocation'; +import type {Location} from '@docusaurus/history'; import './nprogress.css'; nprogress.configure({showSpinner: false}); -interface Props { +interface Props extends RouteComponentProps { routes: RouteConfig[]; delay: number; - location: any; + location: Location; } interface State { nextRouteHasLoaded: boolean; } class PendingNavigation extends React.Component { - previousLocation: any; + previousLocation: Location | null; progressBarTimeout: NodeJS.Timeout | null; constructor(props: Props) { @@ -46,7 +47,7 @@ class PendingNavigation extends React.Component { // is done loading. shouldComponentUpdate(nextProps: Props, nextState: State) { const routeDidChange = nextProps.location !== this.props.location; - const {routes, delay = 1000} = this.props; + const {routes, delay} = this.props; // If `routeDidChange` is true, means the router is trying to navigate to a new // route. We will preload the new route. @@ -128,4 +129,4 @@ class PendingNavigation extends React.Component { } } -export default withRouter(PendingNavigation as any) as any; +export default withRouter(PendingNavigation); diff --git a/packages/docusaurus/src/client/normalizeLocation.ts b/packages/docusaurus/src/client/normalizeLocation.ts index 0d03d1c202..19aa8a3895 100644 --- a/packages/docusaurus/src/client/normalizeLocation.ts +++ b/packages/docusaurus/src/client/normalizeLocation.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -type Location = {pathname: string}; +import type {Location} from '@docusaurus/history'; // Memoize previously normalized pathnames. const pathnames: Record = {};