mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -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
|
@ -8,6 +8,7 @@
|
|||
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { Link, Router, Switch, useLocation } from 'react-router-dom';
|
||||
import { CompatRouter } from 'react-router-dom-v5-compat';
|
||||
import { Route } from '@kbn/shared-ux-router';
|
||||
import { History } from 'history';
|
||||
import {
|
||||
|
@ -185,57 +186,59 @@ export const TodoAppPage: React.FC<{
|
|||
|
||||
return (
|
||||
<Router history={props.history}>
|
||||
<EuiPageBody>
|
||||
<EuiPageHeader>
|
||||
<EuiPageHeaderSection>
|
||||
<EuiTitle size="l">
|
||||
<h1>{props.appTitle}</h1>
|
||||
</EuiTitle>
|
||||
<EuiSpacer />
|
||||
<EuiText>
|
||||
<p>
|
||||
This is a simple TODO app that uses state containers and state syncing utils. It
|
||||
stores state in the URL similar like Discover or Dashboard apps do. <br />
|
||||
Play with the app and see how the state is persisted in the URL.
|
||||
<br /> Undo/Redo with browser history also works.
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiPageHeaderSection>
|
||||
</EuiPageHeader>
|
||||
<EuiPageContent>
|
||||
<EuiPageContentBody>
|
||||
<Switch>
|
||||
<Route path={'/completed'}>
|
||||
<TodoApp filter={'completed'} stateContainer={stateContainer} />
|
||||
</Route>
|
||||
<Route path={'/not-completed'}>
|
||||
<TodoApp filter={'not-completed'} stateContainer={stateContainer} />
|
||||
</Route>
|
||||
<Route path={'/'}>
|
||||
<TodoApp filter={null} stateContainer={stateContainer} />
|
||||
</Route>
|
||||
</Switch>
|
||||
<EuiSpacer size={'xxl'} />
|
||||
<EuiText size={'s'}>
|
||||
<p>Most of kibana apps persist state in the URL in two ways:</p>
|
||||
<ol>
|
||||
<li>Expanded state in rison format</li>
|
||||
<li>
|
||||
Just a state hash. <br />
|
||||
In the URL only the hash from the state is stored. The state itself is stored in
|
||||
the sessionStorage. See `state:storeInSessionStorage` advanced option for more
|
||||
context.
|
||||
</li>
|
||||
</ol>
|
||||
<p>You can switch between these two mods:</p>
|
||||
</EuiText>
|
||||
<EuiSpacer />
|
||||
<EuiButton onClick={() => setUseHashedUrl(!useHashedUrl)}>
|
||||
{useHashedUrl ? 'Use Expanded State' : 'Use Hashed State'}
|
||||
</EuiButton>
|
||||
</EuiPageContentBody>
|
||||
</EuiPageContent>
|
||||
</EuiPageBody>
|
||||
<CompatRouter>
|
||||
<EuiPageBody>
|
||||
<EuiPageHeader>
|
||||
<EuiPageHeaderSection>
|
||||
<EuiTitle size="l">
|
||||
<h1>{props.appTitle}</h1>
|
||||
</EuiTitle>
|
||||
<EuiSpacer />
|
||||
<EuiText>
|
||||
<p>
|
||||
This is a simple TODO app that uses state containers and state syncing utils. It
|
||||
stores state in the URL similar like Discover or Dashboard apps do. <br />
|
||||
Play with the app and see how the state is persisted in the URL.
|
||||
<br /> Undo/Redo with browser history also works.
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiPageHeaderSection>
|
||||
</EuiPageHeader>
|
||||
<EuiPageContent>
|
||||
<EuiPageContentBody>
|
||||
<Switch>
|
||||
<Route path={'/completed'}>
|
||||
<TodoApp filter={'completed'} stateContainer={stateContainer} />
|
||||
</Route>
|
||||
<Route path={'/not-completed'}>
|
||||
<TodoApp filter={'not-completed'} stateContainer={stateContainer} />
|
||||
</Route>
|
||||
<Route path={'/'}>
|
||||
<TodoApp filter={null} stateContainer={stateContainer} />
|
||||
</Route>
|
||||
</Switch>
|
||||
<EuiSpacer size={'xxl'} />
|
||||
<EuiText size={'s'}>
|
||||
<p>Most of kibana apps persist state in the URL in two ways:</p>
|
||||
<ol>
|
||||
<li>Expanded state in rison format</li>
|
||||
<li>
|
||||
Just a state hash. <br />
|
||||
In the URL only the hash from the state is stored. The state itself is stored in
|
||||
the sessionStorage. See `state:storeInSessionStorage` advanced option for more
|
||||
context.
|
||||
</li>
|
||||
</ol>
|
||||
<p>You can switch between these two mods:</p>
|
||||
</EuiText>
|
||||
<EuiSpacer />
|
||||
<EuiButton onClick={() => setUseHashedUrl(!useHashedUrl)}>
|
||||
{useHashedUrl ? 'Use Expanded State' : 'Use Hashed State'}
|
||||
</EuiButton>
|
||||
</EuiPageContentBody>
|
||||
</EuiPageContent>
|
||||
</EuiPageBody>
|
||||
</CompatRouter>
|
||||
</Router>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import { History } from 'history';
|
||||
import { Router } from 'react-router-dom';
|
||||
import { CompatRouter } from 'react-router-dom-v5-compat';
|
||||
|
||||
import {
|
||||
EuiFieldText,
|
||||
|
@ -79,7 +80,7 @@ export const App = ({
|
|||
return (
|
||||
<StateContainersExamplesPage navigateToApp={navigateToApp} exampleLinks={exampleLinks}>
|
||||
<Router history={history}>
|
||||
<>
|
||||
<CompatRouter>
|
||||
<EuiPageBody>
|
||||
<EuiPageHeader>
|
||||
<EuiTitle size="l">
|
||||
|
@ -114,7 +115,7 @@ export const App = ({
|
|||
/>
|
||||
</EuiPageContent>
|
||||
</EuiPageBody>
|
||||
</>
|
||||
</CompatRouter>
|
||||
</Router>
|
||||
</StateContainersExamplesPage>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue