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 actions

An action is a payload of information that sends data to the store; this is the only way views can request or send data to the global state.

In this recipe, we will create the actions to load the initial bookmarks. For now, we will define hardcoded data, but later on, we will request this data from an API on Heroku.

Getting ready

We will continue working on the code from the previous recipe. Make sure to follow those steps in order to have Redux installed, as well as the folder structure that we will use for this project.

How to do it...

  1. First, we need to define the name of the action; let's open the src/redux/modules/bookmarks/actions.js file. In this case, it's going to be a constant that we are going to use later, in the action ...

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