In this section, we're going to connect the components we created in this chapter with Redux. Let's begin by connecting the register component first.
We can define action types of register inside app/containers/Register/actions.js
, as follows:
import { REGISTER_REQUEST, REGISTER_SUCCESS, REGISTER_FAILURE, } from './constants'; export const onRegisterRequest = user => ({ type: REGISTER_REQUEST, user }); export const onRegisterSuccess = user => ({ type: REGISTER_SUCCESS, user }); export const onRegisterFailure = message => ({ type: REGISTER_FAILURE, message, });
We define all the required constants in the constants.js
file, as follows:
export const REGISTER_REQUEST = 'raskLeage/Register/REGISTER_REQUEST'; export const REGISTER_SUCCESS = 'raskLeage/Register/REGISTER_SUCCESS'; export const REGISTER_FAILURE = 'raskLeage/Register/REGISTER_FAILURE';
So far, there is nothing new that we've not discussed before. Now, we can define the reducers.