-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearchParams.js
64 lines (58 loc) · 1.8 KB
/
SearchParams.js
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React, { useState } from "react";
import { ANIMALS } from "@frontendmasters/pet";
const SearchParams = () => {
// const location = "Seattle, WA";
const [location, setLocation] = useState("Seattle, WA"); //Above statement is all about "Hooks" and all the hools starts with "use"
const [animal, setAnimal] = useState("Dog");
const [breed, setBreed] = useState("");
const [breeds, setBreeds] = useState([]);
return (
<div className="search-params">
<form>
<label htmlFor="location">
Location
<input
id="location"
value={location}
placeholder="location"
onChange={(e) => setLocation(e.target.value)}
/>
</label>
<label htmlFor="animal">
Animal
<select
id="animal"
value={animal}
onChange={(e) => setAnimal(e.target.value)}
onBlur={(e) => setAnimal(e.target.value)}
>
<option>All</option>
{ANIMALS.map((animal) => (
<option key={animal} value={animal}>
{animal}
</option>
))}
</select>
</label>
<label htmlFor="breed">
Breed
<select
id="breed"
value={breed}
onChange={(e) => setBreed(e.target.value)}
onBlur={(e) => setBreed(e.target.value)}
>
<option>All</option>
{breeds.map((breedStaring) => (
<option id={breedStaring} value={breedStaring}>
{breedStaring}
</option>
))}
</select>
</label>
<button>Submit</button>
</form>
</div>
);
};
export default SearchParams;