Skip to content

Commit

Permalink
fix route url
Browse files Browse the repository at this point in the history
  • Loading branch information
JunHyeong Kim committed Sep 22, 2024
1 parent 3d814fd commit aabb092
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"deploy": "gh-pages -d build",
"predeploy": "npm run build"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
<title>React App Movie Practice</title>
</head>
<body>
<div id="root"></div>
Expand Down
12 changes: 10 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ function App() {
return (
<Router>
<Routes>
<Route path="/detail/:id" element={<Detail />} />
<Route path="/" element={<Home />} />
<Route
basename={process.env.PUBLIC_URL}
path={`/movie/:id`}
element={<Detail />}
/>
<Route
basename={process.env.PUBLIC_URL}
path={`/`}
element={<Home />}
/>
</Routes>
</Router>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/Movie.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function Movie({ id, img, genres = [], title, score, content }) {
<div className={styles.item} key={id}>
<img className={styles.image} src={img} alt={title} />
<div className={styles.info}>
<Link to={`/detail/${id}`} className={styles.title}>
<Link to={`/movie/${id}`} className={styles.title}>
{title}
</Link>
<p className={styles.genres}>{genres.join(", ")}</p>
Expand Down
1 change: 1 addition & 0 deletions src/router/Detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styles from "../css/Detail.module.css";

function Detail() {
const { id } = useParams();
console.log(id);
const [movieData, setMovie] = useState({});

useEffect(() => {
Expand Down

0 comments on commit aabb092

Please sign in to comment.