Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
dva-router-config
Advanced tools
#### 项目介绍 使用 react-router-config + dva/dynamic 来进行配置化异步加载组件(可嵌套路由)
使用 react-router-config + dva/dynamic 来进行配置化异步加载组件(可嵌套路由)
yarn add dva-router-config
或者
npm i -S dva-router-config
1.基础示例
// routes.js
export default [
{
path: '/',
exact: true,
component: () => import('../IndexPage'),
},
{
path: '/person',
component: () => import('./_layout'),
models: () => [
import('src/models/person'),
],
routes: [
{
path: '/person/redirect',
exact: true,
redirect: '/person/home',
},
{
path: '/person/home',
exact: true,
component: () => import('./Home'),
models: () => [
import('src/models/person/home'),
import('src/models/person/dict'),
],
},
{
path: '/person/mine',
exact: true,
component: () => import('./Mine'),
models: () => [
import('src/models/person/mine'),
import('src/models/person/dict'),
],
},
]
}
];
// router.js
import React from 'react';
import { Router } from 'dva/router';
import { convertRoutes, } from 'dva-router-config';
import routesConfig from './routes/Person/routes';
function RouterConfig({ app, history }) {
return (
<Router history={history}>
{convertRoutes(routesConfig, { app })}
</Router>
);
}
export default RouterConfig;
// _layout.js
import React, { PureComponent } from 'react';
import { Link } from 'react-router-dom';
import { renderRoutes } from 'dva-router-config';
export default class Layout extends PureComponent {
render () {
console.warn('render layout');
const { route = {} } = this.props;
return (
<div>
<ul>
<li>
<Link to={'/person/home'}>home</Link>
</li>
<li>
<Link to={'/person/mine'}>mine</Link>
</li>
<li>
<Link to={'/person/redirect'}>redirect</Link>
</li>
</ul>
{renderRoutes(route.routes)}
</div>
);
}
}
FAQs
#### 项目介绍 使用 react-router-config + dva/dynamic 来进行配置化异步加载组件(可嵌套路由)
We found that dva-router-config demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.