type Sex = "none" | "male" | "female" | "both";
const sexOptions: Sex[] = ["none", "male", "female", "both"];
const [sex, setSex] = useState<Sex>(sexOptions[0]);
// ...
type Props<T extends string> = {
name: string;
state: T;
setState: Dispatch<SetStateAction<T>>;
options: T[];
};
function RadioButtonField<T extends string>({ name, state, setState, options }: Props<T>)
super써야 된다고 생각했지만 extends로 잘 타입 체크 해주기 때문에 용서해드리겠습니다... 휴
댓글 0