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.
enhanced-reducer
Advanced tools
Enhanced version of useReducer which supports middlewares and static getState callback
An enhanced version of react's useReducer
which supports middleware and static getState
callback.
export const useEnhancedReducer
(reducer, initState, initializer, middlewares = [])
[state, dispatch, getState]
The useEnhancedReducer
is fully compatible with useReducer
.
The returned value is sample as of useReducer
, except the additional last value getState
.
The getState
is guaranteed to unchanged (like dispatch
).
useEnhancedReducer
also accepts middlewares
parameter.
Sample middleware:
const logMiddleware = state => getState => next => action => {
console.log('before action', action, getState())
next(action)
console.log('after action', action, getState()) // *NOTE*: because `dispatch(action)`` is not synchronous. it does not guarantee that this getState() call return the value after the action is applied.
}
Check my blog post or these two codepens: 1, 2.
FAQs
Enhanced version of useReducer which supports middlewares and static getState callback
The npm package enhanced-reducer receives a total of 0 weekly downloads. As such, enhanced-reducer popularity was classified as not popular.
We found that enhanced-reducer 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.