refactor: reduce exported members of docusaurus router (#6651)

This commit is contained in:
Joshua Chen 2022-02-11 19:16:13 +08:00 committed by GitHub
parent cfef4755da
commit acf4ae8f96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 7 additions and 12 deletions

View file

@ -240,12 +240,8 @@ declare module '@docusaurus/Translate' {
}
declare module '@docusaurus/router' {
// eslint-disable-next-line import/no-extraneous-dependencies, no-restricted-syntax
export * from 'react-router-dom';
}
declare module '@docusaurus/history' {
// eslint-disable-next-line import/no-extraneous-dependencies, no-restricted-syntax
export * from 'history';
// eslint-disable-next-line import/no-extraneous-dependencies
export {useHistory, useLocation, Redirect, matchPath} from 'react-router-dom';
}
declare module '@docusaurus/useDocusaurusContext' {

View file

@ -7,7 +7,7 @@
import {useEffect, useRef} from 'react';
import {useHistory} from '@docusaurus/router';
import type {Location, Action} from '@docusaurus/history';
import type {Location, Action} from 'history';
type HistoryBlockHandler = (location: Location, action: Action) => void | false;

View file

@ -7,7 +7,7 @@
import {useEffect} from 'react';
import {useLocation} from '@docusaurus/router';
import type {Location} from '@docusaurus/history';
import type {Location} from 'history';
import {usePrevious} from './usePrevious';
import {useDynamicCallback} from './reactUtils';

View file

@ -13,7 +13,7 @@ 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 type {Location} from 'history';
import './nprogress.css';

View file

@ -5,5 +5,4 @@
* LICENSE file in the root directory of this source tree.
*/
// eslint-disable-next-line no-restricted-syntax
export * from 'react-router-dom';
export {useHistory, useLocation, Redirect, matchPath} from 'react-router-dom';

View file

@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import type {Location} from '@docusaurus/history';
import type {Location} from 'history';
// Memoize previously normalized pathnames.
const pathnames: Record<string, string> = {};