Skip to content

Instantly share code, notes, and snippets.

@toxi-kb
Created July 18, 2019 17:53
Show Gist options
  • Select an option

  • Save toxi-kb/c2abd17a72f697054592422db7fa399d to your computer and use it in GitHub Desktop.

Select an option

Save toxi-kb/c2abd17a72f697054592422db7fa399d to your computer and use it in GitHub Desktop.
import React, { useState, useCallback } from "react";
const SearchWithHooks = () => {
const [search, setSearch] = useState("");
const onSearchInputChange = useCallback(e => {
setSearch(e.target.value);
}, []);
return (
<input
onChange={onSearchInputChange}
type="text"
name="search"
placeholder="search with hooks"
value={search}
/>
);
};
export default SearchWithHooks;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment