{"id":26175,"library":"redux-reducers-injector","title":"redux-reducers-injector","description":"Library to dynamically inject reducers into a Redux store at runtime, supporting Hot Module Replacement (HMR) and Server-Side Rendering (SSR). Version 0.3.5 is the latest stable release. It wraps Redux's createStore to accept an uncombined reducer tree and allows adding reducers via injectReducer at any path. Key differentiators include support for nested reducer injection without combineReducers, forced reinjection, bulk injection, and explicit reloadReducer for HMR. Maintained by GuillaumeCisco and based on the work of redux-injector. The package has a small footprint but lacks TypeScript types and relies on lodash.set.","status":"active","version":"0.3.5","language":"javascript","source_language":"en","source_url":"https://github.com/GuillaumeCisco/redux-reducers-injector","tags":["javascript","redux","react"],"install":[{"cmd":"npm install redux-reducers-injector","lang":"bash","label":"npm"},{"cmd":"yarn add redux-reducers-injector","lang":"bash","label":"yarn"},{"cmd":"pnpm add redux-reducers-injector","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; needed to create and interact with the Redux store.","package":"redux","optional":false},{"reason":"Runtime dependency for setting reducer paths using dot notation.","package":"lodash.set","optional":false}],"imports":[{"note":"It is a named export, not default.","wrong":"import createInjectStore from 'redux-reducers-injector'","symbol":"createInjectStore","correct":"import { createInjectStore } from 'redux-reducers-injector'"},{"note":"CommonJS require is acceptable but ESM is preferred. Ensure you are not using default import.","wrong":"const injectReducer = require('redux-reducers-injector').injectReducer","symbol":"injectReducer","correct":"import { injectReducer } from 'redux-reducers-injector'"},{"note":"Named export; spelling is 'injectReducerBulk' (with capital B).","wrong":"import { injectReducerBulk } from 'redux-reducers-injector' (typo: injectReducerBulk vs injectReducerBulk)","symbol":"injectReducerBulk","correct":"import { injectReducerBulk } from 'redux-reducers-injector'"},{"note":"Used for HMR; forces reinjection similarly to injectReducer with force=true.","wrong":"import { reloadReducer } from 'redux-reducers-injector' (confusion with injectReducer)","symbol":"reloadReducer","correct":"import { reloadReducer } from 'redux-reducers-injector'"}],"quickstart":{"code":"import { createStore, combineReducers } from 'redux';\nimport { createInjectStore, injectReducer } from 'redux-reducers-injector';\n\n// Define reducers as a nested object (DO NOT combine)\nconst reducersObject = {\n  router: (state = {}, action) => state,\n  data: {\n    user: (state = {}, action) => state,\n    auth: {\n      loggedIn: (state = false, action) => state,\n      loggedOut: (state = false, action) => state\n    },\n    info: (state = {}, action) => state\n  }\n};\n\n// Create store with inject capability\nconst store = createInjectStore(reducersObject, {});\n\n// Later, inject a new reducer at 'data.form'\nconst formReducer = (state = {}, action) => state;\ninjectReducer('data.form', formReducer);\n\n// Access state as usual\nconsole.log(store.getState());\n// { router: {}, data: { user: {}, auth: { loggedIn: false, loggedOut: false }, info: {}, form: {} } }","lang":"javascript","description":"Demonstrates how to create a Redux store with redux-reducers-injector using an uncombined reducer object and inject a new reducer dynamically."},"warnings":[{"fix":"Pass an object tree of reducer functions (without combineReducers) to createInjectStore.","message":"Do NOT combine reducers with combineReducers before passing to createInjectStore. If you do, you cannot inject into any previously combined reducers.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use string paths like 'data.form' to indicate nesting. For literal dots in keys, escape or avoid dot notation.","message":"injectReducer uses lodash.set for path resolution. Paths with dots are interpreted as nested keys. Ensure your path does not accidentally create unexpected nesting.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"In v0.3.0+, use the optional store parameter in injectReducer to specify a context store. For older versions, avoid SSR or implement per-request store management manually.","message":"If you use SSR, the store reference is stored in the module's scope (singleton). Concurrent requests may share the same store reference, causing race conditions.","severity":"gotcha","affected_versions":"<0.3.0"},{"fix":"Add declare module 'redux-reducers-injector' { ... } or use a type assertion.","message":"The package does not ship TypeScript definitions. Users must create custom .d.ts or use @types/redux-reducers-injector (if available).","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Pass an object of reducer functions without combining them first.","cause":"When passing a combined reducer (result of combineReducers) to createInjectStore, it tries to combine it again causing an error.","error":"TypeError: (0 , _redux.combineReducers) is not a function"},{"fix":"Ensure createInjectStore is called and the store is fully initialized before calling injectReducer. For SSR, pass the store as the context parameter.","cause":"injectReducer called before the store is created or store reference not properly set.","error":"Cannot read property 'replaceReducer' of undefined"},{"fix":"Use createInjectStore (from this package) to create the store, not createStore from redux.","cause":"injectReducer called on a store that was not created with createInjectStore (e.g., created with plain createStore).","error":"Uncaught Error: Store does not have an inject store enhancer. Did you use createInjectStore?"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}