Javascript,Nodejs,MongodDB,WordPress,CSS,PHP

LightBlog

Tuesday, February 26, 2019

what does redux combineReducers do?

Redux always use root reducer function that accept the current state and action as input and it return a new state. in many cases you want to separate sub reducer to operate on each slice of the state then combineReducers is used to do this.combineReducers is a nice way to combine sub reducers.

Syntax:
	
  const rootReducer = combineReducers({
  key1: value1,
  key2: value2
});


Note: inside combineReducers pass plain object.
Example:

const rootReducer = combineReducers({
  a: apples,
  b: bananas
});

1 comment: