'use client' import { useRef } from 'react' import { Control, UseFormRegister, useFieldArray } from 'react-hook-form' import { AddIconBtn, DeleteIconBtn } from 'components' import { nanoid } from '@reduxjs/toolkit' const AddSizes = props => { //? Props const { control, register } = props //? Refs const inputRef = useRef(null) //? Form Hook const { fields, append, remove } = useFieldArray({ name: 'sizes', control, }) //? Handlers const handleAddSize = () => { if (inputRef.current) { const newSize = inputRef.current.value.trim() if (!newSize) return append({ id: nanoid(), size: newSize }) inputRef.current.value = '' } } //? Render(s) return (