O'Reilly logo

React Native By Example by Richard Kho

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reducers

In Vanilla JavaScript, there's an array prototype method called reduce. The purpose of this native reduce function is to return one single reduced value after running a callback and initial value through an entire array's contents.

In Redux, a reducer is a function that takes in your application's state and relevant information passed to it from an action, and then returns one single reduced value for your application's state after executing the code.

Reducers should, as a good practice, be restricted to one reducer per file, for clarity.

There are two really important things we need to know about reducers with Redux:

  • Your application state is never mutated. Instead, a copy is returned with any changed values.
  • Since each reducer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required