NextJs / Form / Add Dynamic Input fields
Add or remove dynamic input field
-
1. Files
); }; export default BillingForm;import { useState } from 'react'; const BillingForm = () => { const [inputs, setInputs] = useState(['']); const handleInputChange = (index, event) => { const values = [...inputs]; values[index] = event.target.value; setInputs(values); }; const addInput = () => { setInputs([...inputs, '']); }; const removeInput = (index) => { const values = [...inputs]; values.splice(index, 1); setInputs(values); }; const handleSubmit = (event) => { event.preventDefault(); // Handle form submission with inputs data console.log(inputs); }; return (