Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Redux Quick Start Guide
  • Toc
  • feedback
Redux Quick Start Guide

Redux Quick Start Guide

By : Lee, Wei, Kumar Mukhiya
3 (1)
close
Redux Quick Start Guide

Redux Quick Start Guide

3 (1)
By: Lee, Wei, 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 (10 chapters)
close

Mocking react-router-dom for testing

We already explored the ways that we can test react-router-dom in Chapter 2, Testing. In this chapter, we will explore some of the advanced-level testing problems that we can face in react-router-dom testing.

We already have JEST configured in our application. Let's consider the HomePage/index component. In the preceding snippet, we are using the Link component from react-router-dom, but instead of using it in a normal way, we are passing the function as the child component. If you are not aware of this, we suggest reading about it (https://medium.com/merrickchristensen/function-as-child-components-5f3920a9ace9):

import React from "react";
import { Route, Link } from "react-router-dom";

const MenuLink = ({ to, ...rest }) => (
<Route path={to}>
{({ match }) => (
<li className={match ?...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete