From 69d236f5a2697e41093d8ae5efb8628c9c49ed0a Mon Sep 17 00:00:00 2001 From: grapefruit13 Date: Thu, 25 Apr 2024 16:24:34 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20formMethod=20props=EC=97=90=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/components/InputRadio/InputRadio.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/lib/components/InputRadio/InputRadio.tsx b/src/lib/components/InputRadio/InputRadio.tsx index 82be1abe..0bea1fd5 100644 --- a/src/lib/components/InputRadio/InputRadio.tsx +++ b/src/lib/components/InputRadio/InputRadio.tsx @@ -1,11 +1,16 @@ import classNames from 'classnames/bind'; -import { useFormContext } from 'react-hook-form'; +import { FieldValues, UseFormRegister } from 'react-hook-form'; import styles from './InputRadio.module.scss'; const cx = classNames.bind(styles); +type FormMethod = { + register: UseFormRegister; +}; + type InputRadioProps = { + formMethod: FormMethod; label: string; name: string; radioList: { id: string; value: number; label: string }[]; @@ -14,8 +19,16 @@ type InputRadioProps = { onClick?: (value: number) => void; }; -const InputRadio = ({ label, name, radioList, defaultCheckIndex = 0, color = 'purple', onClick }: InputRadioProps) => { - const { register } = useFormContext(); +const InputRadio = ({ + formMethod, + label, + name, + radioList, + defaultCheckIndex = 0, + color = 'purple', + onClick, +}: InputRadioProps) => { + const { register } = formMethod; return (