GithubHelp home page GithubHelp logo

react-router-movies's Introduction

Client Side Routing w/ React Router v.5

Topics:

  • React Router
  • Using Link and NavLink to navigate to specific routes
  • Passing Route Parameters
  • Passing props to components rendered by the Router

Instructions

Task 1: Project Set-up

  • Fork this repository, then clone your fork.

  • NOTE You have 2 servers that you will be running here so read these instructions carefully.

  • In the root of this directory: Run npm install to download dependencies.

  • Run the server using npm start or node server.js. (Don't worry too much about this process, you'll get used to doing this and it will be explained more in the future).

  • In a separate terminal cd into the client folder and run npm install to download dependencies.

  • Still inside the client folder run npm start to run the client application.

  • Once your application is up and running on the client, you should see a browser window that looks like this at localhost:3000 (although the port number will be different if 3000 is being used).

    Movies Home

Task 2a: MVP

Set up Routes

  • Wrap your app with the router.
  • Inside your App file add two routes.
    • one route for / that loads the MovieList component. This component will need the movies injected into it via props.
    • one route that will take an id parameter after/movies/ (ex: /movies/2, /movies/3 where the id is dynamic). This route should load the Movie component.

Add Functionality

  • When a user clicks on the movie card inside MovieList they should be taken to /movies/{id of clicked movie here} to see the details of the selected movie.
  • You will need to modify line 8 of Movie.js to get the id of the selected movie from the URL.
  • Add functionality so the Home button on the SavedList component navigates back to home.
  • You should now be able to navigate back and forth between the list of movies and the detailed view of a single movie.

Task 2b: Exit Ticket

Once you begin, you will have 15 minutes to answer the questions here.

The completion of these questions is mandatory for MVP. However, passing the quiz doesn't affect your standing as a Lambda School student whatsoever. This is Lambda School testing itself! Please answer honestly and to the best of your ability without using external references.

Task 3: Stretch Goals

If you have completed Parts 1 & 2 feel free to move on to these stretch goals.

Refactor so that our code is DRY

  • You may notice that we are using very similar JSX in the Movie component and in the MovieDetails component in MovieList.js. The main difference is the list of stars, which only exists in the "detailed" view of the Movie component.
  • Create a new component in MovieCard.js that returns a Movie Card. Then remove the old code from Movie and MovieDetails and instead return the new MovieCard component.
  • The Movie Card should be flexible enough to handle displaying a movie with or without the list of stars.

Add Save Movie functionality

  • You will notice there is a 'Saved Movies' component that we are not currently using. In this step you will add the functionality to save a movie. You will need to pass the addToSavedList function to the Movie component. Once you have done that you will need to add a click handler to the save button. You will need to uncomment lines 24-27 in Movie.js to complete this.

Turn your Saved Movie list into Links

  • Your list of saved movies should be links to the movie itself. Study and understand what the saveMovie function is doing.

Turn your Saved Movie Links into NavLinks

  • Navlink

Submission Format

  • Submit a Pull-Request to merge <firstName-lastName> Branch into main (student's Repo). Please don't merge your own pull request
  • Fill out your module retrospective form here with a link to your PR

react-router-movies's People

Contributors

cmgorton avatar dswhitely1 avatar dustinmyers avatar jasonsbarr avatar ladrillo avatar luishrd avatar rodrigograca31 avatar ryan-hamblin avatar seanchen1991 avatar sunjieming avatar tetondan avatar zoelud avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.