Skip to content

Instantly share code, notes, and snippets.

@sadam1807
Last active June 9, 2022 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sadam1807/baa04b0594dab608001b2b51f29880b8 to your computer and use it in GitHub Desktop.
Save sadam1807/baa04b0594dab608001b2b51f29880b8 to your computer and use it in GitHub Desktop.
import React, { useState } from 'react'
const App = () => {
const [formValues, setFormValues] = useState([{ name: "", email : ""}])
return (
<form onSubmit={handleSubmit}>
{formValues.map((element, index) => (
<div className="form-inline" key={index}>
<label>Name</label>
<input type="text" name="name" value={element.name || ""} onChange={e => handleChange(index, e)} />
<label>Email</label>
<input type="text" name="email" value={element.email || ""} onChange={e => handleChange(index, e)} />
{
index ?
<button type="button" className="button remove" onClick={() => removeFormFields(index)}>Remove</button>
: null
}
</div>
))}
<div className="button-section">
<button className="button add" type="button" onClick={() => addFormFields()}>Add</button>
<button className="button submit" type="submit">Submit</button>
</div>
</form>
)
}
export default App
@ajay-duple
Copy link

hcfhdfhdfhdfdfgdf

@ajay-duple
Copy link

ajay-duple commented Jun 9, 2022

fdhd fhfdhf h fghfh fghfg hfgh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment