796e73ae5a
* refactor(doc): change to new structure * docs: add database docs * docs: add collection docs * docs: add db field examples * docs(api): fix filename and menu path * docs: add database docs * docs: add db operators doc * docs: add resourcer menu * docs: add resourcer docs * docs: fix api docs * docs: refactor api menu structure * feat: update docs (#830) * feat: updates * feat: update docs * chore: ignore docs from ci Co-authored-by: Junyi <mytharcher@users.noreply.github.com> Co-authored-by: mytharcher <mytharcher@gmail.com> * docs: add database methods docs * docs: add missed api * docs: fix api docs * feat: update development docs (#833) * feat: update development docs * feat: update docs * feat: update docs * docs: add first plugin example (#834) * feat: update docs * feat: update docs * docs: fix typo Co-authored-by: chenos <chenlinxh@gmail.com>
35 lines
770 B
Markdown
35 lines
770 B
Markdown
# RouteSwitch
|
|
|
|
```tsx | pure
|
|
import React from 'react';
|
|
import { Link, MemoryRouter as Router } from 'react-router-dom';
|
|
import { RouteRedirectProps, RouteSwitchProvider, RouteSwitch } from '@nocobase/client';
|
|
|
|
const Home = () => <h1>Home</h1>;
|
|
const About = () => <h1>About</h1>;
|
|
|
|
const routes: RouteRedirectProps[] = [
|
|
{
|
|
type: 'route',
|
|
path: '/',
|
|
exact: true,
|
|
component: 'Home',
|
|
},
|
|
{
|
|
type: 'route',
|
|
path: '/about',
|
|
component: 'About',
|
|
},
|
|
];
|
|
|
|
export default () => {
|
|
return (
|
|
<RouteSwitchProvider components={{ Home, About }}>
|
|
<Router initialEntries={['/']}>
|
|
<Link to={'/'}>Home</Link>, <Link to={'/about'}>About</Link>
|
|
<RouteSwitch routes={routes} />
|
|
</Router>
|
|
</RouteSwitchProvider>
|
|
);
|
|
};
|
|
``` |