Skip to content

fdiogo/react-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting hooked to React

This is a web app that consumes the MovieDB API. You can check the API docs here

We're using a proxy server for the API which automatically injects an api_key query parameter so you don't have to ask for your own. This is its url: https://reactworkshop-api.herokuapp.com/

If you would like to continue this afterwards don't forget to change all API calls into the original API: https://api.themoviedb.org/

Requirements

  • Node: >= 10.16.0
  • Yarn: >= 1.19.0

Setup

Clone the repository

git clone [email protected]:fdiogo/react-workshop.git

If you have nvm installed, then run:

nvm use

Install dependencies

yarn install

Run the project

yarn start

Challenges

Each challenge has its own branch. Before you start the challenge you must checkout to the corresponding branch. Before you move on to the next challenge first do git stash -u so that you can later continue if you want. Every challenge has a list of todos in the code to help you in the process.

Challenge 1

Build search input with a button and text blow with the query, all this using setState.

Branch: challenge1

Note: we only want to show the query once the user has submitted it.

Todos


Challenge 2

Add useEffect to fetch the search results.

Branch: challenge2

Todos


Challenge 3

Implement the closing detection for modals with a useEffect with a cleanup

Branch: challenge3

Todos

  • Add a useEffect
  • Add a window mousedown listener to detect outside clicks
  • Add a window keyup listener to detect Escape presses

Challenge 4

Memoize the cards in the search results

Branch: challenge4

Todos


Challenge 5

Convert the value of the search input into a ref

Branch: challenge5

Todos


Challenge 6

Use refs directly on elements

Branch: challenge6

Todos


Challenge 7

Instead of prop drilling the API configuration create a shared context and consume it using useContext directly.

Branch: challenge7

Todos


Challenge 8

Implement the loading and error state in SearchResults only using useState

Branch: challenge8

Todos


Challenge 9

Convert the loading, error and data state into a single useReducer

Branch: challenge9

Todos


Challenge 10

Move the reducer inside SearchResults into a shared context.

Branch: challenge10


Challenge 11

Move the fetch inside the SearchContextProvider.

Branch: challenge11

Future work

We left you some suggestions for future work on this project if you feel like. These don't have solutions made by us so they're completely up to you.

Challenge 12

Add caching to the search reducer.

Hint: Use the page and query to determine if you already have the data in memory.


Challenge 13

Implement a component to render the people media type.


Challenge 14

Add a button to add a tv show or movie to your favorites.

Links:


Challenge 15

Implement the favorites page.


Challenge 16

Add a button to add a tv show or movie to your watchlist.

Links:


Challenge 17

Implement the watchlist page.


Challenge 18

Add filters for the type of media you'd like to search for.

Links:


Challenge 19

Add a discover page


Challenge 20

Add the features you would find useful and deploy your app to netlify or other cloud services.