
Research
/Security News
Malicious npm Packages Target WhatsApp Developers with Remote Kill Switch
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
redux-immer
Advanced tools
redux-immer is used to create an equivalent function of Redux combineReducers that works with immer state.
redux-immer
is used to create an equivalent function of Redux combineReducers that works with immer
state.
Like redux-immutable
but for immer
Using npm:
$ npm install --save redux-immer
redux-first-history
/ react-router-redux
/ connected-react-router
)store.js
import { createStore, applyMiddleware } from 'redux';
import { combineReducers } from 'redux-immer';
import produce from 'immer';
// Reducers
import { user } from './user';
import { catalog } from './catalog';
export const store = createStore(
combineReducers(produce, {
user,
catalog,
// ...
}),
// applyMiddleware...
);
user.js
const initialState = {
id: null,
profile: {}
};
export const user = (state = initialState, action) => {
switch (action.type) {
case LOAD_USER:
state.id = action.id;
state.profile = action.profile;
return state; // or just return; (immer way)
default:
return state; //important return state on default for initialState!!
}
};
catalog.js
const initialState = [];
export const catalog = (state = initialState, action) => {
switch (action.type) {
case LOAD_CATALOG:
state = action.data;
return state; // or just return; (immer way)
default:
return state; //important return draft on default for initialState!!
}
};
You may call combineReducers
at any level of the reducer hierarchy. It doesn't have to happen at the top. In fact you may use it again to split the child reducers that get too complicated into independent grandchildren, and so on. (exact as original redux.combineReducer https://redux.js.org/api/combinereducers)
Let me know what do you think!
Enjoy it? Star this project! :D
any idea? let me know and contribute!
See Contributors.
FAQs
redux-immer is used to create an equivalent function of Redux combineReducers that works with immer state.
The npm package redux-immer receives a total of 5,130 weekly downloads. As such, redux-immer popularity was classified as popular.
We found that redux-immer 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
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.
Research
/Security News
Socket uncovered 11 malicious Go packages using obfuscated loaders to fetch and execute second-stage payloads via C2 domains.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.