O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

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

Defining reducers

At this point, we have created some actions for our application--basically, a CRUD of bookmarks. As mentioned previously, actions define that something happened; however, we still need to figure out what to do with the data on the action. By using a reducer, we can define how the data will be stored on the global state.

In this recipe, we will introduce a reducer to set the bookmarks, from the actions defined on the previous recipe, to the global state.

Getting ready

This recipe depends on the previous recipe; make sure to start from the beginning of this chapter to avoid any problems or confusion.

How to do it...

  1. Let's start by opening the src/redux/modules/bookmarks/reducer.js file. Then we need to import all the action types we ...

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