Book Image

Redux Quick Start Guide

By : James Lee, Tao Wei, Suresh Kumar Mukhiya
Book Image

Redux Quick Start Guide

By: James Lee, Tao Wei, Suresh Kumar Mukhiya

Overview of this book

Starting with a detailed overview of Redux, we will follow the test-driven development (TDD) approach to develop single-page applications. We will set up JEST for testing and use JEST to test React, Redux, Redux-Sage, Reducers, and other components. We will then add important middleware and set up immutableJS in our application. We will use common data structures such as Map, List, Set, and OrderedList from the immutableJS framework. We will then add user interfaces using ReactJS, Redux-Form, and Ant Design. We will explore the use of react-router-dom and its functions. We will create a list of routes that we will need in order to create our application, and explore routing on the server site and create the required routes for our application. We will then debug our application and integrate Redux Dev tools. We will then set up our API server and create the API required for our application. We will dive into a modern approach to structuring our server site components in terms of Model, Controller, Helper functions, and utilities functions. We will explore the use of NodeJS with Express to build the REST API components. Finally, we will venture into the possibilities of extending the application for further research, including deployment and optimization.
Table of Contents (16 chapters)
Title Page
Copyright and Credits
About Packt

Understanding selectors

As the name specifies, selectors are functions that are utilized to select a subset of data from a bigger collection of data. A selector holds two types of information, as follows:

  1. Information about where to find a particular subset of data
  2. Return the requested subset of data

Why selectors?

Redux provides all state transformations and how these transformations mutate the store. However, it doesn't discuss a prescribed way for components to query the store. This is where the selector comes in. As mentioned, the Redux store stores a global store for an entire application to reduce the complexity and we need a mechanism for querying this store. The use of selectors is one of the possible solutions to this problem. 

We can access the store through direct references, as follows:

const subsetOfState = store.someStateRoot.someProperty[key]

There are two issues with this approach, as follows:

  1. The application must know the actual shape of the store and whether the shape of the store...