From 31f8fffab1b952407eae7627f9f4c6cba3ab4c79 Mon Sep 17 00:00:00 2001 From: d0422 Date: Mon, 13 Nov 2023 22:52:19 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20[FE]=20useInput=20=ED=9B=85=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20input=EC=9D=98=20state,=20change=ED=95=A8=EC=88=98?= =?UTF-8?q?=EB=A5=BC=20=EC=B6=94=EC=83=81=ED=99=94=ED=95=9C=20useInput=20?= =?UTF-8?q?=ED=9B=85=20=EC=B6=94=EA=B0=80=20(#32)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontEnd/src/hooks/useInput.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 frontEnd/src/hooks/useInput.ts diff --git a/frontEnd/src/hooks/useInput.ts b/frontEnd/src/hooks/useInput.ts new file mode 100644 index 00000000..0519b3c1 --- /dev/null +++ b/frontEnd/src/hooks/useInput.ts @@ -0,0 +1,11 @@ +import { useState } from 'react'; + +export default function useInput(initialValue: string) { + const [value, setValue] = useState(initialValue); + + const onChange = (event: React.ChangeEvent) => { + if (event.target) setValue(event.target.value); + }; + + return { inputValue: value, onChange }; +}