Registry / web-framework / redux-injector

redux-injector

JSON →
library0.1.0jsnpmunverified

A library for dynamically injecting reducers into a Redux store at runtime, enabling lazy loading of reducers and plugin architectures. Version 0.1.0 is the only stable release. Unlike static combineReducers, it uses createInjectStore to accept an uncombined reducer tree and injectReducer to add reducers by path (e.g., 'date.form'). Relies on lodash.set. Release cadence is unknown; last update was years ago. Alternative to static reducer composition or other dynamic Redux solutions like Redux Toolkit's reducer injection examples. Minimal documentation and no recent maintenance, so consider compatibility with modern Redux carefully.

npm install redux-injector
INSTALL
IMPORT
SIG · REDUX-INJECTOR
R
redux-injector
web-frameworkjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createInjectStore
import { createInjectStore } from 'redux-injector'
import createInjectStore from 'redux-injector'
This is a named export, not a default export.
injectReducer
import { injectReducer } from 'redux-injector'
const injectReducer = require('redux-injector').injectReducer
CommonJS requires valueless, but ESM named import is preferred.
default import (nonexistent)
import { createInjectStore, injectReducer } from 'redux-injector'
import reduxInjector from 'redux-injector'
No default export exists; using named exports only.

Demonstrates creating a store with createInjectStore and dynamically injecting a reducer using injectReducer with a dot path.

import { createStore, combineReducers } from 'redux'; import { createInjectStore, injectReducer } from 'redux-injector'; // Reducer tree (uncombined) const reducersObject = { counter: (state = 0, action) => { switch (action.type) { case 'INCREMENT': return state + 1; default: return state; } } }; // Create store with inject capability const store = createInjectStore(reducersObject, {}); // Later, inject a new reducer injectReducer('todos', (state = [], action) => { switch (action.type) { case 'ADD_TODO': return [...state, action.payload]; default: return state; } }); store.dispatch({ type: 'INCREMENT' }); store.dispatch({ type: 'ADD_TODO', payload: 'Learn redux-injector' }); console.log(store.getState()); // Output: { counter: 1, todos: ['Learn redux-injector'] }
Debug
Known issues
gotchainjectReducer uses lodash.set so you must ensure path supports dot notation; missing intermediate objects are created automatically.
fix
Be careful with path strings; they follow lodash.set conventions.
affects: >=0.1.0
gotchaDo NOT combine reducers with combineReducers before passing to createInjectStore; pass the plain object tree instead.
fix
Pass an object of reducer functions without combineReducers.
affects: >=0.1.0
deprecatedPackage has not been updated in years; may be incompatible with latest Redux and React versions.
fix
Consider alternatives like Redux Toolkit's dynamic reducer injection or useReducer-based solutions.
affects: >=0.1.0
gotchainjectReducer mutates the store's reducer map and may cause subtle bugs if injected after reducers have been combined.
fix
Inject before any complex state changes or use immutable injection patterns.
affects: >=0.1.0
Errors
Common errors & fixes
Uncaught Error: Reducer "..." returned undefined during initialization.
You passed a combined reducer (result of combineReducers) to createInjectStore instead of a plain object tree.
fix
Pass the uncombined reducer object tree, not the result of combineReducers.
TypeError: Cannot read property 'set' of undefined
Missing lodash dependency (lodash.set not available).
fix
Install lodash: npm install lodash
TypeError: state is not a function
Trying to use injectReducer on a store created with regular createStore, not createInjectStore.
fix
Use createInjectStore from redux-injector instead of createStore.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
reduxoptionalPeer dependency: wraps createStore and uses combineReducers.
lodashrequiredUsed for lodash.set to set reducer paths.
Agent activity
4 hits · last 30 days
node
4
Resources
redux-injector — npm install redux-injector · libregistry