Remove useMatchedRoutes/MatchedRouteContext (#76788) (#76947)

We're not using them.
This commit is contained in:
Nathan L Smith 2020-09-08 10:48:50 -05:00 committed by GitHub
parent 0241423f67
commit 690d8eb507
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 56 deletions

View file

@ -27,7 +27,6 @@ import { ApmPluginContext } from '../context/ApmPluginContext';
import { LicenseProvider } from '../context/LicenseContext';
import { LoadingIndicatorProvider } from '../context/LoadingIndicatorContext';
import { LocationProvider } from '../context/LocationContext';
import { MatchedRouteProvider } from '../context/MatchedRouteContext';
import { UrlParamsProvider } from '../context/UrlParamsContext';
import { ApmPluginSetupDeps } from '../plugin';
import { createCallApmApi } from '../services/rest/createCallApmApi';
@ -100,15 +99,13 @@ export function ApmAppRoot({
<i18nCore.Context>
<Router history={history}>
<LocationProvider>
<MatchedRouteProvider routes={routes}>
<UrlParamsProvider>
<LoadingIndicatorProvider>
<LicenseProvider>
<App />
</LicenseProvider>
</LoadingIndicatorProvider>
</UrlParamsProvider>
</MatchedRouteProvider>
<UrlParamsProvider>
<LoadingIndicatorProvider>
<LicenseProvider>
<App />
</LicenseProvider>
</LoadingIndicatorProvider>
</UrlParamsProvider>
</LocationProvider>
</Router>
</i18nCore.Context>

View file

@ -1,34 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import React, { useMemo, ReactChild } from 'react';
import { matchPath } from 'react-router-dom';
import { useLocation } from '../hooks/useLocation';
import { BreadcrumbRoute } from '../components/app/Main/ProvideBreadcrumbs';
export const MatchedRouteContext = React.createContext<BreadcrumbRoute[]>([]);
interface MatchedRouteProviderProps {
children: ReactChild;
routes: BreadcrumbRoute[];
}
export function MatchedRouteProvider({
children,
routes,
}: MatchedRouteProviderProps) {
const { pathname } = useLocation();
const contextValue = useMemo(() => {
return routes.filter((route) => {
return matchPath(pathname, {
path: route.path,
});
});
}, [pathname, routes]);
return (
<MatchedRouteContext.Provider value={contextValue} children={children} />
);
}

View file

@ -1,12 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { useContext } from 'react';
import { MatchedRouteContext } from '../context/MatchedRouteContext';
export function useMatchedRoutes() {
return useContext(MatchedRouteContext);
}