-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathSearch.js
31 lines (28 loc) · 819 Bytes
/
Search.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
import { useRouter } from "next/router";
import React from "react";
import { DebounceInput } from "react-debounce-input";
import { json2query } from "../util";
export const Search = (props) => {
const router = useRouter();
const { query = "" } = router.query;
const handleChange = (e) => {
router.push(
`?${json2query({
...router.query,
query: e.target.value,
})}`
);
};
return (
<div className="px-2 mt-4 w-full">
<h3 className="text-xs text-gray-700 uppercase mb-2 font-bold">Search</h3>
<DebounceInput
minLength={2}
debounceTimeout={300}
className="bg-gray-200 p-2 hover:bg-gray-100 rounded-md w-full text-xs"
placeholder="🔍 Search by token id e.g., 4003"
onChange={handleChange}
/>
</div>
);
};