Skip to content

Commit

Permalink
feat: [FE] useInput 훅 추가
Browse files Browse the repository at this point in the history
input의 state, change함수를 추상화한 useInput 훅 추가
(#32)
  • Loading branch information
d0422 committed Nov 13, 2023
1 parent e8fa0e9 commit 31f8fff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions frontEnd/src/hooks/useInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useState } from 'react';

export default function useInput(initialValue: string) {
const [value, setValue] = useState(initialValue);

const onChange = (event: React.ChangeEvent<HTMLInputElement>) => {
if (event.target) setValue(event.target.value);
};

return { inputValue: value, onChange };
}

0 comments on commit 31f8fff

Please sign in to comment.