"use client"; import { useFieldArray, useForm } from "react-hook-form"; export interface IChallengesStepFields { section_title: string; section_description: string; challenges: { icon: string; title: string; description: string; }[]; } const useChallengesStepPresenter = () => { const { register, handleSubmit, control, watch, formState: { errors }, } = useForm({ defaultValues: { challenges: [{ icon: "", title: "", description: "" }], }, }); const { fields, append, remove } = useFieldArray({ control, name: "challenges", }); const onSubmit = (data: IChallengesStepFields) => { console.log(data); }; return { register, handleSubmit, errors, onSubmit, fields, append, remove, control, watch, }; }; export default useChallengesStepPresenter;