diff --git a/README.md b/README.md
index e1509e4e47..216c4c874c 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ Topics:
* When a user clicks on a movie card they should be taken to `/movies/{id of movie here}` to see the details for the selected movie.
* You will need to modify line 13 of `Movie.js` in order to accept the correct id for the movie selected.
* 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 individual movies and the home screen.
+** You should now be able to navigate back and forth between the individual movies and the home screen.
## Stretch Goals.
diff --git a/client/src/App.js b/client/src/App.js
index 740adc7a8a..27e327cb57 100644
--- a/client/src/App.js
+++ b/client/src/App.js
@@ -1,18 +1,22 @@
import React, { useState } from 'react';
-
+import { Route } from 'react-router-dom';
+import Movie from './Movies/Movie';
+//import MovieCard from './Movies/MovieCard';
+import MovieList from './Movies/MovieList';
import SavedList from './Movies/SavedList';
const App = () => {
- const [savedList, setSavedList] = useState( [] );
+ const [savedList, setSavedList] = useState([]);
const addToSavedList = movie => {
- setSavedList( [...savedList, movie] );
+ setSavedList([...savedList, movie]);
};
return (
-
Replace this Div with your Routes
+
+
);
};
diff --git a/client/src/Movies/Movie.js b/client/src/Movies/Movie.js
index 25dd470bee..ffd97a872e 100644
--- a/client/src/Movies/Movie.js
+++ b/client/src/Movies/Movie.js
@@ -2,24 +2,26 @@ import React, { useState, useEffect } from 'react';
import axios from 'axios';
const Movie = (props) => {
- const [movie, setMovie] = useState({});
-
+ const [movie, setMovie] = useState();
+ console.log('Movie', props, props.match.params.id);
+
useEffect(() => {
- const id = 1;
+ const id = props.match.params.id;
+ console.log(id)
// change ^^^ that line and grab the id from the URL
// You will NEED to add a dependency array to this effect hook
- axios
- .get(`http://localhost:5000/api/movies/${id}`)
- .then(response => {
- setMovie(response.data);
- })
- .catch(error => {
- console.error(error);
- });
-
- },[]);
-
+ axios
+ .get(`http://localhost:5000/api/movies/${id}`)
+ .then(response => {
+ setMovie(response.data);
+ })
+ .catch(error => {
+ console.error(error);
+ });
+
+ }, [props.match.params.id]);
+
// Uncomment this only when you have moved on to the stretch goals
// const saveMovie = () => {
// const addToSavedList = props.addToSavedList;
diff --git a/client/src/Movies/MovieList.js b/client/src/Movies/MovieList.js
index ab22a906a1..73aab2b151 100644
--- a/client/src/Movies/MovieList.js
+++ b/client/src/Movies/MovieList.js
@@ -1,5 +1,7 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';
+import { Link } from 'react-router-dom'
+
const MovieList = props => {
const [movies, setMovies] = useState([])
@@ -14,10 +16,10 @@ const MovieList = props => {
console.error('Server Error', error);
});
}
-
+
getMovies();
}, []);
-
+
return (