1. Getting Started
2. Basic Concepts
3. Handlers
4. Advanced Concepts
4.0.1 Creating Custom Reducer# Creating Custom Reducer# Passing create Reducer or own reducer4.0.2 Modifying api end points reducer constants4.0.3 Don't reset on setting to initial state4.0.4 Cancelling Api Calls4.0.5 Axios Interceptors4.0.6 Inject saga and reducer to the store4.0.7 Inject saga and reducer to the store by using hooks4.0.8 Util Functions4.0.9 PARAMS4.1.0 Handling Multiple tasks
# Creating Custom Reducer
import { HOC, commonConstants, store } from "react-boilerplate-redux-saga-hoc";const AuthenticationHOC = HOC({ handlers: [] })({initialState: {profile: {},},apiEndPoints: {TEST_API: {},REGISTER_API: {url: `users/user-signup/`,method: "POST",},},constantReducer: ({ type, state, action, constants, initialState }) => {if (type === "LOGOUT") return initialState;return state;},name: "Auth",});/*Example: const { dispatch } = props;dispatch({ type: "LOGOUT" });*/
# Passing create Reducer or own reducer
import { HOC, commonConstants, store } from "react-boilerplate-redux-saga-hoc";import { combineReducers } from "redux";import { connectRouter } from "connected-react-router";import history from "utils/history";import globalReducer from "containers/App/reducer";import languageProviderReducer from "containers/LanguageProvider/reducer";/*** Merges the main reducer with the router state and dynamically injected reducers*//* this is the pattern for passing custom reducer *//*** Merges the main reducer with the router state and dynamically injected reducers*/export default function createReducer(injectedReducers = {}) {const rootReducer = combineReducers({global: globalReducer,language: languageProviderReducer,router: connectRouter(history),...injectedReducers,});return rootReducer;}const AuthenticationHOC = HOC({ createReducer })({initialState: {profile: {},},apiEndPoints: {TEST_API: {},REGISTER_API: {url: `users/user-signup/`,method: "POST",},},constantReducer: ({ type, state, action, constants, initialState }) => {if (type === "LOGOUT") return initialState;return state;},name: "Auth",});/*Example: const { dispatch } = props;dispatch({ type: "LOGOUT" });*/