'use client' import { useRef } from 'react' import { Control, UseFormRegister, useFieldArray } from 'react-hook-form' import { AddIconBtn, DeleteIconBtn } from 'components' const DetailsList = props => { //? Props const { categoryName, name, control, register } = props //? Refs const newDetailRef = useRef(null) //? Form const { fields, append, remove } = useFieldArray({ name, control, }) //? Handlers const handleAddNewDetail = () => { if (newDetailRef.current) { append({ title: newDetailRef.current.value }) newDetailRef.current.value = '' } } //? Render return (
{name === 'info' ? 特点 : 规格}{' '} {categoryName}
{fields.map((field, index) => ( ))}
名称
remove(index)} />
) } export default DetailsList