Introduction
In this lesson, we discuss the basics of Reducers and their importance in Redux.
In computer science, the word reducer
is commonly associated with a function that takes an array or object and converts it to a simpler structure. E.g, summing all the items in an array.
In Redux, the role of the reducer is somewhat different: reducers create a new state out of the old one, based on an action.
In essence, a reducer is a simple JavaScript function that receives two parameters (two objects—the previous state and an action) and returns an object (a modified copy of the first argument):
Get hands-on with 1400+ tech skills courses.