Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-router-redux-saga-model
Advanced tools
将 react-router 、redux、与 [redux-saga-model](https://github.com/tomsonTang/redux-saga-model) 进行封装
将 react-router 、redux、与 redux-saga-model 进行封装
npm i react-router-redux-saga-model
很多时候我们的 Provider
需要手动和 store 进行关联,同时还需要手动配置 history 与 redux 的同步,以及设置响应 history 的 Router。
这里将其透明化:
import {BrowserRouterProvider} from 'react-router-redux-saga-model'
ReactDOM.render(
<BrowserRouterProvider>
<div>
<Link to="/about">关于</Link>
<Link to="/">主页</Link>
<Route exact path="/" component={Index}/>
<Route path="/about" component={About}/>
</div>
</BrowserRouterProvider>,
document.querySelector('#root')
)
/* 输出 */
<Provider store={createStore()}>
<ConnectedRouter history={createBrowserHistory()}>
<div>
<Link to="/about">关于</Link>
<Link to="/">主页</Link>
<Route exact path="/" component={Index}/>
<Route path="/about" component={About}/>
</div>
</ConnectedRouter>
</Provider>
RouterType 对应 history
的 3 中 history 类型:
RouterType.Browser
RouterType.Hash
RouterType.Memory
RouterProvider
有时候我们有特殊需要需要设置 默认的 state,middleware,reducer(由于使用了 sagaModel,正常是不需要提供额外的 reducer)
import {RouterProvider,RouterType} from 'react-router-redux-saga-model';
const initialState = {};
const initialReducer = {};
const initialMiddleware = [];
<RouterProvider type={RouterType.Browser} state={initialState} reducers={initialReducer} middleware={initialMiddleware}>
<div>
<Link to="/about">关于</Link>
<Link to="/">主页</Link>
<Route exact path="/" component={Index}/>
<Route path="/about" component={About}/>
</div>
</RouterProvider>
import {BrowserRouterProvider} from 'react-router-redux-saga-model'
import indexModel from './view/index/indexModel.js';
const models = [indexModel];
ReactDOM.render(
<BrowserRouterProvider modles={models}>
<div>
<Link to="/about">关于</Link>
<Link to="/">主页</Link>
<Route exact path="/" component={Index}/>
<Route path="/about" component={About}/>
</div>
</BrowserRouterProvider>,
document.querySelector('#root')
)
这时候所有的 sagaModels 都会被解析并处理。
import React from 'react';
import ReactDOM from 'react-dom';
import {Route} from 'react-router';
import {Link} from 'react-router-dom';
import {BrowserRouterProvider} from 'react-router-redux-saga-model'
import About from './view/about/index.jsx';
import Index from './view/index/index.jsx';
import loading from './plugins/loading.js';
import indexModel from './view/index/indexModel.js';
const App = (sagaModel) =>{
// sagaModel API
sagaModel.register(IndexModel);
return (
<div>
<Link to="/about">关于</Link>
<Link to="/">主页</Link>
<Route exact path="/" component={Index}/>
<Route path="/about" component={About}/>
</div>
)
};
ReactDOM.render(
<BrowserRouterProvider children={App} plugins={[loading]}/>,
document.querySelector('#root')
);
通过传入一个回调,拿到 sagaModel 动态设置相关处理。
react-router-redux-saga-mode-example
npm install
npm start
FAQs
react-router-redux-saga-model
The npm package react-router-redux-saga-model receives a total of 4 weekly downloads. As such, react-router-redux-saga-model popularity was classified as not popular.
We found that react-router-redux-saga-model demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.