mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Add react-router-dom-v5-compat (#159173)
## Summary Prep work for bumping react-router to v6 Following https://github.com/remix-run/react-router/discussions/8753 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2fba1b651e
commit
09577fa0af
42 changed files with 715 additions and 613 deletions
|
@ -11,6 +11,7 @@ import { CoreStart } from '@kbn/core/public';
|
|||
import { of } from 'rxjs';
|
||||
import { createMemoryHistory } from 'history';
|
||||
import { Router } from 'react-router-dom';
|
||||
import { CompatRouter } from 'react-router-dom-v5-compat';
|
||||
import { MemoryHistory } from 'history';
|
||||
import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common';
|
||||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
|
||||
|
@ -38,11 +39,13 @@ export const render = (
|
|||
|
||||
return testLibRender(
|
||||
<Router history={history}>
|
||||
<KibanaContextProvider services={{ ...core }}>
|
||||
<UrlParamsProvider>
|
||||
<EuiThemeProvider>{component}</EuiThemeProvider>
|
||||
</UrlParamsProvider>
|
||||
</KibanaContextProvider>
|
||||
<CompatRouter>
|
||||
<KibanaContextProvider services={{ ...core }}>
|
||||
<UrlParamsProvider>
|
||||
<EuiThemeProvider>{component}</EuiThemeProvider>
|
||||
</UrlParamsProvider>
|
||||
</KibanaContextProvider>
|
||||
</CompatRouter>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@ import { History, Location } from 'history';
|
|||
import moment from 'moment-timezone';
|
||||
import * as React from 'react';
|
||||
import { MemoryRouter, Router } from 'react-router-dom';
|
||||
import { CompatRouter } from 'react-router-dom-v5-compat';
|
||||
import type { UrlParams } from './types';
|
||||
import { UrlParamsContext, UrlParamsProvider } from './url_params_context';
|
||||
|
||||
|
@ -164,25 +165,27 @@ describe('UrlParamsContext', () => {
|
|||
|
||||
const wrapper = mount(
|
||||
<Router history={history}>
|
||||
<UrlParamsProvider>
|
||||
<UrlParamsContext.Consumer>
|
||||
{({ urlParams, refreshTimeRange }) => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<span id="data">{JSON.stringify(urlParams, null, 2)}</span>
|
||||
<button
|
||||
onClick={() =>
|
||||
refreshTimeRange({
|
||||
rangeFrom: 'now-1d/d',
|
||||
rangeTo: 'now-1d/d',
|
||||
})
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
}}
|
||||
</UrlParamsContext.Consumer>
|
||||
</UrlParamsProvider>
|
||||
<CompatRouter>
|
||||
<UrlParamsProvider>
|
||||
<UrlParamsContext.Consumer>
|
||||
{({ urlParams, refreshTimeRange }) => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<span id="data">{JSON.stringify(urlParams, null, 2)}</span>
|
||||
<button
|
||||
onClick={() =>
|
||||
refreshTimeRange({
|
||||
rangeFrom: 'now-1d/d',
|
||||
rangeTo: 'now-1d/d',
|
||||
})
|
||||
}
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
}}
|
||||
</UrlParamsContext.Consumer>
|
||||
</UrlParamsProvider>
|
||||
</CompatRouter>
|
||||
</Router>
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue