React Boilerplate CRA Template
  • README
  • Quick Start
  • Understanding react-boilerplate
  • Tools
    • CLI & Scaffolding
    • Editor Configuration
    • Package Managers
  • Building Blocks
    • Building Blocks
    • The Slice
      • Redux & Toolkit
      • Reselect
      • Redux-Saga
      • Redux Injectors
    • Async Components
    • Routing
    • i18n Internationalization & Pluralization
    • Styling (CSS)
    • Testing
  • Deployment
    • AWS
    • Azure
    • Heroku
    • Netlify
  • Misc
    • FAQ
Powered by GitBook
On this page

Was this helpful?

  1. Building Blocks
  2. The Slice

Redux Injectors

PreviousRedux-SagaNextAsync Components

Last updated 4 years ago

Was this helpful?

is an official react-boilerplate companion library. We built it so that it can be used and maintained independently from react-boilerplate. It allows you to dynamically load reducers and sagas as needed, instead of loading them all upfront. This has some nice benefits, such as avoiding having to manage a big global list of reducers and sagas. It also facilitates more effective use of .

You can find the main repo for the library and read the docs .

Usage

import {
  useInjectSaga,
  useInjectReducer,
  SagaInjectionModes,
} from 'utils/redux-injectors';
import { saga } from './saga';
import { reducer } from '.';

export function SomeComponent() {
  useInjectReducer({ key: 'SomeComponent', reducer });
  useInjectSaga({
    key: 'SomeComponent',
    saga,
    mode: SagaInjectionModes.DAEMON,
  });
  // ...
}

Note: Importing redux-injectors from utils/redux-injectors will add extra type-safety.

redux-injectors
code-splitting
here
here