Skip to content

Commit

Permalink
feat: 검색 API 호출 시, 검색 페이지 입력값과 Navbar 입력값 동기화하기(#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgksqkr committed Jun 19, 2024
1 parent 057f234 commit e8dfa5e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hooks/useInput.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRouter } from 'next/navigation';
import { ChangeEvent, useCallback, useState } from 'react';
import { ChangeEvent, useCallback, useEffect, useState } from 'react';

const useInput = (initialValue: string) => {
const router = useRouter();
Expand All @@ -25,6 +25,11 @@ const useInput = (initialValue: string) => {
}
};

// SearchInput과 HeaderSearchInput 동기화
useEffect(() => {
setValue(initialValue);
}, [initialValue]);

return { value, isFocused, handleChange, handleFocus, handleBlur, handleKeydown };
};

Expand Down

0 comments on commit e8dfa5e

Please sign in to comment.