score:3

Accepted answer
  • make sure to destructure the details from props in editsectioncomponent.
  • in your parent, the initial state i.e. details is defined as an array. it need to be an object.
  • also while doing setdetails, you need to specify the key. (not a dynamic name in your case)

updated code is here:

const editsectioncomponent = ({
    editcaption,
    editname,
    details,
}) => {
    const {name,caption} = details;

    return (
        <input
        type="text"
        classname="imagenamedetails"
        value={name}
        onchange={e => editname(e.target)}
        />  
    )
}

const [details, setdetails] = usestate({name: '', caption: ''});

const editname = target => {
    setdetails(prev => ({...prev, name: target.value}))
};

Related Query

More Query from same tag