React Observatory
  • Introduction
  • Motivation
  • Dynamic Injection
    • Reducers
    • Epics
  • API Reference
    • applyAsyncEpics
    • applyAsyncReducers
    • composeReducerCreator
    • createRootEpic
    • injectEpic
    • injectReducer
    • withAction
    • withRouterAction
Powered by GitBook
On this page
  • Arguments
  • Returns
  • Example: Composing a Reducer creator
  • ./src/reducers
  1. API Reference

composeReducerCreator

PreviousapplyAsyncReducersNextcreateRootEpic

Last updated 6 years ago

A helper function that takes the Object with Reducers and returns a reducer creator for dynamic reducer injection by

The reducer creator is only required for setting-up the store.

Arguments

  1. reducers (Object): An object whose values correspond to different reducing functions that need to be combined into one. See the notes below for some rules every passed reducer must follow.

Returns

(Function): A function that is used to create a set of reducers and will be used by enhancer for dynamic Reducer injection. Serves as a replacement for

Example: Composing a Reducer creator

./src/reducers

import { composeReducerCreator } from '@react-observatory/inject-reducer'

const counter = (state = 0, action) => {
  if (action.type === 'Up') {
    return state + 1
  }
  return state
}

export default composeReducerCreator({
  counter
})
applyAsyncReducers.
applyAsyncReducers
combineReducers.