-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMovie.jsx
More file actions
32 lines (28 loc) · 814 Bytes
/
Movie.jsx
File metadata and controls
32 lines (28 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { useState } from "react";
import { Link, useNavigate } from "react-router-dom";
import "../styles/Movie.css";
function Movie() {
const [movieId, setMovieId] = useState("");
const navigate = useNavigate();
function handleMovieIdSubmit(e) {
e.preventDefault();
navigate(`/movie/${movieId}`);
}
return (
<div className="movie-container">
<h1>Enter a Movie id</h1>
<form onSubmit={handleMovieIdSubmit}>
<input
type="text"
placeholder="Enter a movie id"
value={movieId}
onChange={(e) => setMovieId(e.target.value.replace(/\D/, ""))}
pattern="\d*"
/>
<button type="submit">Watch</button>
</form>
<Link to={"/movie/339403"}>Watch sample movie</Link>
</div>
);
}
export default Movie;