Created
June 8, 2019 18:13
-
-
Save JackHowa/4fdfb27dbc042b977d3a01d33045acb7 to your computer and use it in GitHub Desktop.
this is for the v5 with hooks, new pet api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
import { ANIMALS } from "@frontendmasters/pet"; | |
const SearchParams = () => { | |
// api limited to seattle and sf | |
const [location, setLocation] = useState("Seattle, WA"); | |
const [animal, setAnimal] = useState("dog"); | |
const [breed, setBreed] = useState(""); | |
return ( | |
<div className="search-params"> | |
<p>{location}</p> | |
<form> | |
<label htmlFor="location"> | |
location | |
<input | |
onChange={e => setLocation(e.target.value)} | |
id="location" | |
value={location} | |
placeholder={"Location"} | |
/> | |
</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)} | |
disabled={false} | |
> | |
{breed} | |
</select> | |
</label> | |
</form> | |
</div> | |
); | |
}; | |
export default SearchParams; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment