November 2018
Beginner
502 pages
10h 22m
English
A reducer is a function that is responsible for creating new state for a given action. So, the function takes in an action with the current state and returns the new state. In this section, we'll create a reducer for the two actions we have created on products.
import { Reducer } from "redux";import { IProductsState, ProductsActions, ProductsActionTypes } from "./ProductsTypes";
We are importing the Reducer type from Redux along with types for the actions and state we created earlier.
const initialProductState: IProductsState = { products: [], productsLoading: false};
So, ...
Read now
Unlock full access