How to do it...

We are going to use the same code we created in the last recipe (Repository: /Chapter05/Recipe1/store) and add some modifications:

  1. First, we need to create new folders: src/actions, src/reducers, src/components/Coins, and src/shared/utils.
  1. The first file we need to create issrc/actions/actionTypes.js, where we need to add our constants for our actions:
export const FETCH_COINS_REQUEST = 'FETCH_COINS_REQUEST';export const FETCH_COINS_SUCCESS = 'FETCH_COINS_SUCCESS';export const FETCH_COINS_ERROR = 'FETCH_COINS_ERROR';
File: src/actions/actionTypes.js
  1. Maybe you are wondering why we need to create a constant with the same name as the string. It is because, when using constants, we can't have duplicate constant names (we ...

Get React Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.