'use client'; import { useState } from "react"; const Form = ({ initialData, submitFunction }) => { const [formData, setFormData] = useState( initialData ); const handleSubmit = async (event) => { event.preventDefault(); //q = formData; //addQuestion( q ); //console.log( `Adding question ${JSON.stringify(q)}` ); await submitFunction( formData ); } const handleChange = (event) => { const { name, value } = event.target; setFormData( (prevData) => ({ ...prevData, [name]: value })); } return (
{Object.entries( initialData ).map( (elem) => { return( )})}
); } export default Form;