Skip to content

Commit b11bc43

Browse files
committed
set "Enter" as constant
1 parent 4c515ba commit b11bc43

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/HomePage/Search.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import React, { useRef } from "react";
22
import { useSearch } from "../../theme/Root";
33
import styles from "./search.module.css";
44

5+
const ENTER_KEY = "Enter";
6+
57
export function Search({ searchTags }: { searchTags: string[] }): JSX.Element {
68
const { setQuery } = useSearch();
79
const inputRef = useRef(null);
@@ -12,7 +14,7 @@ export function Search({ searchTags }: { searchTags: string[] }): JSX.Element {
1214
}
1315

1416
function handleEnter(event) {
15-
if (event.key === "Enter") {
17+
if (event.key === ENTER_KEY) {
1618
handleSearch();
1719
}
1820
}
@@ -22,7 +24,7 @@ export function Search({ searchTags }: { searchTags: string[] }): JSX.Element {
2224
}
2325

2426
function handleTagEnter(event, tag: string) {
25-
if (event.key === "Enter") {
27+
if (event.key === ENTER_KEY) {
2628
setQuery(tag);
2729
}
2830
}

0 commit comments

Comments
 (0)