How to do it...

Let's test our Redux containers:

  1. Redux containers should not have any JSX code; the best practice is to have mapStateToProps and mapDispatchToProps in our connect method passing another component (such as a Layout component) in the export, for example, let's see our Todo List Container:
  // Dependencies  import { connect } from 'react-redux';  import { bindActionCreators } from 'redux';  // Components  import Layout from '../components/Layout';  // Actions  import { fetchTodo } from '../actions';  export default connect(({ todo }) => ({    todo: todo.list  }), dispatch => bindActionCreators(    {      fetchTodo    },    dispatch  ))(Layout);
File: src/client/todo/container/index.js
  1. You might be wondering what exactly we need to test in here. Well, ...

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.