File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,3 +97,10 @@ packages/
9797## 라이선스
9898
9999MIT © Viva Republica, Inc. 자세한 내용은 [ LICENSE] ( ./LICENSE ) 를 참고하세요.
100+
101+ <a title =" Toss " href =" https://toss.im " >
102+ <picture >
103+ <source media="(prefers-color-scheme: dark)" srcset="https://static.toss.im/logos/png/4x/logo-toss-reverse.png">
104+ <img alt="Toss" src="https://static.toss.im/logos/png/4x/logo-toss.png" width="100">
105+ </picture >
106+ </a >
Original file line number Diff line number Diff line change @@ -97,3 +97,10 @@ We welcome contributions from everyone! Please check our contribution guide.
9797## License
9898
9999MIT © Viva Republica, Inc. See [ LICENSE] ( ./LICENSE ) for details.
100+
101+ <a title =" Toss " href =" https://toss.im " >
102+ <picture >
103+ <source media="(prefers-color-scheme: dark)" srcset="https://static.toss.im/logos/png/4x/logo-toss-reverse.png">
104+ <img alt="Toss" src="https://static.toss.im/logos/png/4x/logo-toss.png" width="100">
105+ </picture >
106+ </a >
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ function AutoCompleteInput() {
2626 const [results, setResults] = useState <SearchResult []>([]);
2727 const [isLoading, setLoading] = useState (false );
2828 const [isOpen, setOpen] = useState (false );
29- const searchTimeoutRef = useRef <NodeJS .Timeout >(null );
3029 const containerRef = useRef <HTMLDivElement >(null );
3130
3231 useEffect (() => {
@@ -44,17 +43,13 @@ function AutoCompleteInput() {
4443 }, []);
4544
4645 useEffect (() => {
47- if (searchTimeoutRef .current ) {
48- clearTimeout (searchTimeoutRef .current );
49- }
50-
5146 if (query .trim ().length === 0 ) {
5247 setResults ([]);
5348 return ;
5449 }
5550
5651 setLoading (true );
57- searchTimeoutRef . current = setTimeout (async () => {
52+ const timeoutId = setTimeout (async () => {
5853 try {
5954 const response = await fetch (` /api/search?q=${query } ` );
6055 const data = await response .json ();
@@ -66,11 +61,7 @@ function AutoCompleteInput() {
6661 }
6762 }, 300 );
6863
69- return () => {
70- if (searchTimeoutRef .current ) {
71- clearTimeout (searchTimeoutRef .current );
72- }
73- };
64+ return () => clearTimeout (timeoutId );
7465 }, [query ]);
7566
7667 return (
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ function AutoCompleteInput() {
2626 const [results, setResults] = useState <SearchResult []>([]);
2727 const [isLoading, setLoading] = useState (false );
2828 const [isOpen, setOpen] = useState (false );
29- const searchTimeoutRef = useRef <NodeJS .Timeout >(null );
3029 const containerRef = useRef <HTMLDivElement >(null );
3130
3231 useEffect (() => {
@@ -44,17 +43,13 @@ function AutoCompleteInput() {
4443 }, []);
4544
4645 useEffect (() => {
47- if (searchTimeoutRef .current ) {
48- clearTimeout (searchTimeoutRef .current );
49- }
50-
5146 if (query .trim ().length === 0 ) {
5247 setResults ([]);
5348 return ;
5449 }
5550
5651 setLoading (true );
57- searchTimeoutRef . current = setTimeout (async () => {
52+ const timeoutId = setTimeout (async () => {
5853 try {
5954 const response = await fetch (` /api/search?q=${query } ` );
6055 const data = await response .json ();
@@ -66,11 +61,7 @@ function AutoCompleteInput() {
6661 }
6762 }, 300 );
6863
69- return () => {
70- if (searchTimeoutRef .current ) {
71- clearTimeout (searchTimeoutRef .current );
72- }
73- };
64+ return () => clearTimeout (timeoutId );
7465 }, [query ]);
7566
7667 return (
You can’t perform that action at this time.
0 commit comments