Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
redux-dumb-router
Advanced tools
A simple minded routing solution for reactjs/redux
Essentially, it's just lightweight middleware to bridge redux to mjackson/history.
/* store.js */
import { createStore, combineReducers, applyMiddleware } from 'redux'
import { createHistory } from 'history'
import { createRouterMiddleware } from 'redux-dumb-router'
import { routerReducer as router } from 'redux-dumb-router'
const history = createHistory()
const routerMiddleware = createRouterMiddleware(history)
const middleware = applyMiddleware(routerMiddleware)
const reducer = combineReducers({ router })
const store = createStore(reducer, middleware)
export default store
/* app.js */
import { routerActionCreators } from 'redux-dumb-router'
import store from './store.js'
store.dispatch(routerActionCreators.start())
let state = store.getState()
// state.router = { location: { pathname: [pathname of current URL] ... }}
/* app.js */
store.dispatch(routerActionCreators.goto('/blog'))
let state = store.getState()
// state.router = { location: { pathname: '/blog' ... }}
Note: This assumes you've completed Step 1 of "Get Started" above.
/* root.jsx */
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { routerActionCreators } from '../src'
import store from './store.js'
import Routes from './routes.jsx'
store.dispatch(routerActionCreators.start())
ReactDOM.render(
<Provider store={store}>
<Routes />
</Provider>,
document.getElementById('root')
)
/* routes.jsx */
import React from 'react'
import { connect } from 'react-redux'
// -- route components --
import Home from './Home.jsx'
import About from './About.jsx'
import Blog from './Blog.jsx'
import NotFound from './NotFound.jsx'
export default connect(mapState)(render)
function mapState(state) {
return {
location: state.router.location
}
}
function render(props) {
switch (props.location.pathname) {
case '/':
return <Home />
case '/home':
return <Home />
case '/about':
return <About />
case '/blog':
return <Blog />
default:
return <NotFound />
}
}
Take a look at the source (specifically src/create-middleware.js). You'll discover additional functionality to do stuff like:
FAQs
A simple minded routing solution for reactjs/redux
The npm package redux-dumb-router receives a total of 2 weekly downloads. As such, redux-dumb-router popularity was classified as not popular.
We found that redux-dumb-router 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.