Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@jackgreen/react-router-view
Advanced tools
全局路由组件,配置化路由,所有 Switch/Route 的地方都可以替换
exclude: /node_modules(?!\/react-router-view)/
import { BrowserRouter } from 'react-router-dom'
import RouterView, { RouteConfig } from 'react-router-view'
// 路由配置
const routes: RouteConfig[] = [
{ path: '/single', component: Single },
{
path: `/multi`,
component: Multi,
childRoutes: [
{
path: '/multi/child1',
component: Child1
},
{
path: '/multi/child2',
component: Child2
}
]
}
]
function App(props) {
return (
<div>
<BrowserRouter>
// 一级路由需要在 router 组件中,透传 props,并且传入 routes
<RouterView {...props} routes={routes} />
</BrowserRouter>
</div>
)
}
function Multi(props) {
return (
<div>
// 二级路由开始,只需要透传 props
<RouterView {...props} />
</div>
)
}
ReactDOM.render(<App />, document.getElementById('app'))
继承 RouteProps
import { RouteProps } from 'react-router'
export interface RouteConfig extends RouteProps {
path: string
component: React.ComponentType<any>
childRoutes?: RouteConfig[]
}
路由访问 url
react 组件
子路由
Swtich Route Link
等路由组件必须要在 Router
组件中使用,只能以源码的方式引入,在项目中 babel 配置包含 node_modules/react-router-view
,随着项目一起打包。
// 打包后的部分代码
// 直接使用 Swtich 会报错
// You should not use <Switch> outside a <Router>
function ReactRouterView(props) {
var routes = props.routes
return React.createElement(reactRouterDom.Switch)
}
FAQs
全局路由组件,配置化路由,所有 Switch/Route 的地方都可以替换
We found that @jackgreen/react-router-view 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.