
Security News
OWASP 2025 Top 10 Adds Software Supply Chain Failures, Ranked Top Community Concern
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.
redux-inject-reducer-and-saga
Advanced tools
Code highly influenced by react-boilerplate with some modifications If you need more informations read react-boilerplate docs they are great.
The library allows us to add reducers and sagas after the store was initialized. Since library wants to be universal and not decide what will be used it allows to use redux-thunk and redux-saga simultaneously. With preference to use redux-saga. The library is set to use immutable but developers can use simple object and arrays as state in reducers. react-router v4 is set and route reducer is included as default reducer.
yarn add redux-inject-reducer-and-saga
npm install --save-dev redux-inject-reducer-and-saga
["last 4 versions"]import {configureStore} from "redux-inject-reducer-and-saga";
const store = configureStore();
expect(store.getState()).toMatchSnapshot();
/*
Immutable.Map {
"route": Immutable.Map {
"location": null,
},
}
*/
import {configureStore} from "redux-inject-reducer-and-saga";
function staticReducer(state = null) {
return state;
}
const reducers = {config: staticReducer};
const store = configureStore(reducers);
expect(store.getState()).toMatchSnapshot();
/*
Immutable.Map {
"route": Immutable.Map {
"location": null,
},
"config": null, // 💉
}
*/
import {configureStore} from "redux-inject-reducer-and-saga";
function staticReducer(state = null) {
return state;
}
const reducers = {config: staticReducer};
const initialState = {config: true};
const store = configureStore(reducers, initialState);
expect(store.getState()).toMatchSnapshot();
/*
Immutable.Map {
"route": Immutable.Map {
"location": null,
},
"config": true, // 💉
}
*/
import React from "react";
import {mount} from "enzyme";
import {compose, bindActionCreators} from "redux";
import {connect} from "react-redux";
import {put, takeLatest} from "redux-saga/effects";
import {configureStore, injectReducer, injectSaga} from "redux-inject-reducer-and-saga";
const getWrappedSagaComponent = prefix => {
// constants
const NAME_SEND = `${prefix}/NAME_SEND`;
const NAME_SET = `${prefix}/NAME_SET`;
// actions
const nameSendAction = name => ({
type: NAME_SEND,
payload: name,
});
const nameSetAction = name => ({
type: NAME_SET,
payload: name,
});
// reducers
const reducer = (state = "no-name", {type, payload}) => {
switch (type) {
case NAME_SET:
return payload;
default:
return state;
}
};
// sagas
function* nameSetSaga(action) {
const name = action.payload;
yield put(nameSetAction(name));
}
function* saga() {
yield takeLatest(NAME_SEND, nameSetSaga);
}
const withReducer = injectReducer({key: `${prefix}/testReducer`, reducer});
const withSaga = injectSaga({key: `${prefix}/testSaga`, saga});
const withConnect = connect(
state => ({name: state.get(`${prefix}/testReducer`)}), // mapStateToProps
dispatch => bindActionCreators({nameSend: nameSendAction}, dispatch), // mapDispatchToProps
);
type Props = {
name: string,
nameSend: string => void,
};
class Component extends React.Component<Props, any> {
componentDidMount() {
this.props.nameSend(`Name ${prefix}`);
}
render() {
return <span>{this.props.name}</span>;
}
}
// prettier-ignore
return compose(
withReducer,
withSaga,
withConnect,
)(Component);
};
const store = configureStore();
it("component A, with reducer and saga", () => {
const WrappedComponent = getWrappedSagaComponent("A");
const component = mount(<WrappedComponent />, {context: {store}});
expect(store.getState()).toMatchSnapshot();
/*
Immutable.Map {
"route": Immutable.Map {
"location": null,
},
"A/testReducer": "Name A", // 💉
}
*/
});
it("component B, with reducer and saga", () => {
const WrappedComponent = getWrappedSagaComponent("B");
// store used from previous example
const component = mount(<WrappedComponent />, {context: {store}});
expect(store.getState()).toMatchSnapshot();
/*
Immutable.Map {
"route": Immutable.Map {
"location": null,
},
"A/testReducer": "Name A",
"B/testReducer": "Name B", // 💉
}
*/
});
import React from "react";
import {mount} from "enzyme";
import {compose, bindActionCreators} from "redux";
import {connect} from "react-redux";
import {configureStore, injectReducer, injectSaga} from "redux-inject-reducer-and-saga";
const getWrappedThunkComponent = prefix => {
// constants
const NAME_SET = `${prefix}/NAME_SET`;
const nameSetAction = name => ({
type: NAME_SET,
payload: name,
});
// reducers
const reducer = (state = "no-name", {type, payload}) => {
switch (type) {
case NAME_SET:
return payload;
default:
return state;
}
};
// thunks
const nameSendThunk = name => dispatch => dispatch(nameSetAction(name));
const withReducer = injectReducer({key: `${prefix}/testReducer`, reducer});
const withConnect = connect(
state => ({name: state.get(`${prefix}/testReducer`)}), // mapStateToProps
dispatch => bindActionCreators({nameSend: nameSendThunk}, dispatch), // mapDispatchToProps
);
type Props = {
name: string,
nameSend: string => void,
};
class Component extends React.Component<Props, any> {
componentDidMount() {
this.props.nameSend(`Name ${prefix}`);
}
render() {
return <span>{this.props.name}</span>;
}
}
// prettier-ignore
return compose(
withReducer,
withConnect,
)(Component);
};
it("component C, with reducer and saga", () => {
const WrappedComponent = getWrappedThunkComponent("C");
// store used from previous examples
const component = mount(<WrappedComponent />, {context: {store}});
expect(store.getState()).toMatchSnapshot();
/*
Immutable.Map {
"route": Immutable.Map {
"location": null,
},
"A/testReducer": "Name A",
"B/testReducer": "Name B",
"C/testReducer": "Name C", // 💉
}
*/
});
More complex test: https://github.com/marcelmokos/redux-inject-reducer-and-saga/blob/master/src/configureStore.test.js
FAQs
Inject reducer and saga anywhere in the application.
We found that redux-inject-reducer-and-saga 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.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.