- React Router
- Navigating to specific routes
- Consuming URL Parameters
- Passing props to components rendered by the Router
- Fork this repository, then clone your fork.
- Execute
npm installto download dependencies. Thereact-router-domlibrary is already installed! - Execute
npm run startto launch your Movies application in Chrome.
Once your application is up and running, you should see a browser window that looks like this at http://localhost:3000.
Once you are done your application will have two routes:
- Wrap the
Appcomponent withBrowserRouterinsrc/index.js. - Inside your App file add two routes.
- one route for
/that loads theMovieListcomponent. This component will need the movies injected into it via props. - one route that will take an
idparameter after/movies/(EG:/movies/2,/movies/3where the id is dynamic). This route should load theMoviecomponent.
- one route for
- When a user clicks on the movie card inside
MovieListthey should be taken to/movies/{id of clicked movie here}to see the details of the selected movie. - You will need to modify line 7 of
Movie.jsto get the id of the selected movie from the URL. - Add functionality so the
Homebutton on theSavedListcomponent 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.
If you have completed Parts 1 & 2 feel free to move on to these stretch goals.
- You may notice that we are using very similar JSX in the
Moviecomponent and in theMovieDetailscomponent inMovieList.js. The main difference is the list of stars, which only exists in the "detailed" view of theMoviecomponent. - Create a new component in
MovieCard.jsthat returns a Movie Card. Then remove the old code fromMovieandMovieDetailsand instead return the newMovieCardcomponent. - The Movie Card should be flexible enough to handle displaying a movie with or without the list of stars.
- 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
addToSavedListfunction to theMoviecomponent. 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 inMovie.jsto complete this.
- Your list of saved movies should be links to the movie itself. Study and understand what the
saveMoviefunction is doing.
- Submit a link to your repository in canvas.