RN TS Boilerplate
  • Introduction
  • Getting Started
  • Why Use This Template
  • CLI Tools
  • Building Blocks
    • Building Blocks
    • The Slice
      • Redux & Toolkit
      • Reselect
      • Redux-Saga
      • Redux Injectors
    • Navigation
    • Splash Screen
Powered by GitBook
On this page

Was this helpful?

  1. Building Blocks
  2. The Slice

Redux Injectors

PreviousRedux-SagaNextNavigation

Last updated 3 years ago

Was this helpful?

is an official react-boilerplate companion library. It was built 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.

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
here
here