Redux React Module Project: Movie CRUD

This module explored the redux philosophy, creation of the redux store and using connect to link state and action to arbitrary components.

Objectives

  • Understand the use and setup of Redux

  • Use Redux to connect existing state and actions to components

  • Use the combineReducer method to combine states.

  • Build reducers, actions and redux connections from scratch

Introduction

In this project, you take a fairly complex application used to search a movie database and connect it to two different reducers through redux. You will both connect existing state definitions and build entire reducer / redux pairings from scratch.

Make sure to complete your tasks one at a time and complete test each task before proceeding forward.

Instructions

Task 1: Project Set Up

Task 2: Project Requirements

Setup Redux

The DOM and movie reducer has been provided for you, but it's up to to connect it to redux...

Connecting the Movie reducer

Within the reducers folder is the movieReducers file. We have the state already setup it up here with some initial data. Let's connect that state to our component.

Connecting the Delete and Add Movie actions

Looks like you got a good handle on mapping stateToProps! Now let's connect some actions.

Build out the favorites reducer

Alright! Now that the movie reducer is complete, you have the chance to build a reducer from scratch to handle favorite movie functionality. We will also work on combining reducers.

Build out the favorites actions

Now is your chance to build our all the rest of the app on your own. You can do this!

  1. Add in reducer cases, action creators and event handler code for the following actions:

  • toggleFavorites : Switches the displayFavorites state value between true and false. When displayFavorites is true, the favorite button does not show on the Movie page.

  • addFavorites: Adds in a new movie object into the favorites list.

  • removeFavorite: Removes a movie Object from the favorites list with an id passed in.

Stretch goals

  • It makes sense to not allow the user to favorite an item if favorites is not displayed. Add in means for the favorite button to ONLY display if displayFavorite is true.

  • Right now, you can favorite the same movie multiple times. Change the addFavorite action to only add in a new favorite if it doesn't already exist.

  • Add in the ability to remove a movie from the favorites list if that movie is removed from our main movie list.

  • Style to your heart's content ❤️

Last updated