
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
@simprl/dynamic-reducer
Advanced tools
dynamicReducer - reducer for Redux in which you can add or remove child reducers
Add reducer to the store when component mount and remove reducer from the store when component unmount
For more information read this article: Put a Soul into a React-Redux Project
Example with hook useReducer :
const Container = () => {
const { dispatch, useReducer } = useStore()
useReducer('books', booksReducer)
return <button onClick={() => dispatch({ space: 'book', type: 'ADD_BOOK' })} >
add book
</button>
}
Modules 'react' and 'redux' should be installed.
Run NPM command:
npm i @simprl/dynamic-reducer
Or yarn:
yarn add @simprl/dynamic-reducer
import { createStore } from 'redux';
import { reducer as dynamicReducer } from '@simprl/dynamic-reducer';
const { reducer, addReducer } = dynamicReducer()
const store = createStore(reducer)
const exStore = {
...store,
useReducer: (name, reducer) => {
useEffect(
() => addReducer(name, reducer, store.dispatch),
[ name, reducer ]
);
},
}
If your project has static reducers, you can keep they and add the dynamic reducer to the store with static reducers:
import { createStore, combineReducers } from 'redux';
import { reducer as createDynamicReducer } from '@simprl/dynamic-reducer';
import reducer1 from './ducks/reducer1';
import reducer2 from './ducks/reducer2';
const { reducer: dynamic, addReducer } = createDynamicReducer()
const store = createStore(combineReducers({
reducer1,
reducer2,
dynamic,
}))
const exStore = {
...store,
useReducer: (name, reducer) => {
useEffect(
() => addReducer(name, reducer, store.dispatch),
[ name, reducer ]
);
},
}
You can use Provider from 'react-redux' or create your own context
const App = () => {
return <Provider store={exStore} >
<Container />
</Provider>
}
const { dispatch, useReducer } = useStore()
useReducer('books', booksReducer)
FAQs
dynamicReducer - reducer for Redux in which you can add or remove child reducers
We found that @simprl/dynamic-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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.