https://github.com/FS05-PART3-TEAM2/5-fav_photo-team2-fe/tree/main/src/components/common/input
DropDown: https://github.com/FS05-PART3-TEAM2/5-fav_photo-team2-fe/blob/main/src/components/common/input/Dropdown.tsx
Form에 zodResolver 사용:
https://github.com/FS05-PART3-TEAM2/5-fav_photo-team2-fe/blob/main/src/components/auth/SignupForm.tsx
공식문서: https://react-hook-form.com/docs/useform#resolver
import { useForm } from "react-hook-form"
import { zodResolver } from "@hookform/resolvers/zod"
import * as z from "zod"
const schema = z.object({
name: z.string(),
age: z.number(),
})
type Schema = z.infer<typeof schema>
const App = () => {
const { register, handleSubmit } = useForm<Schema>({
resolver: zodResolver(schema),
})
const onSubmit = (data: Schema) => {
console.log(data)
}
return (
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register("name")} />
<input {...register("age", { valueAsNumber: true })} type="number" />
<input type="submit" />
</form>
)
}