Reducers

Learn about Reducers in Redux.

Introduction to reducers

Reducers are a general programming concept. They are not Redux-specific.

A reducer is a function that has the following characteristics:

  • Reducers are pure functions.
  • Reducers don’t create any side effects.
  • Reducer functions receive some data as arguments and perform an immutable operation on them.

Let’s understand the characteristics above one by one.

Pure and impure functions

Pure functions always return the same output for the same given arguments.

In the following example, we declare a function, sum(), which receives two arguments, a and b, and returns a+b ...