Skip to content

Instantly share code, notes, and snippets.

@JackHowa
Created June 8, 2019 18:13
Show Gist options
  • Save JackHowa/4fdfb27dbc042b977d3a01d33045acb7 to your computer and use it in GitHub Desktop.
Save JackHowa/4fdfb27dbc042b977d3a01d33045acb7 to your computer and use it in GitHub Desktop.
this is for the v5 with hooks, new pet api
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