Created
July 17, 2021 17:39
-
-
Save DZuz14/d270a24c70def7334c2a1dddd37efffe to your computer and use it in GitHub Desktop.
h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Form, FormGroup, Button } from "react-bootstrap"; | |
import formData from "./formData"; | |
import useForm from "./useForm"; | |
const SomeComponent = () => { | |
const { fields, setFields, handleSubmit, success } = useForm(formData); | |
return ( | |
<div css={CSS}> | |
<Form onSubmit={handleSubmit}> | |
{fields.map((field) => ( | |
<FormGroup key={field.name}> | |
<Form.Label>{field.name}</Form.Label> | |
<Form.Control | |
type={field.type} | |
name={field.name} | |
value={field.value} | |
onChange={setFields} | |
placeholder={field.placeholder} | |
/> | |
</FormGroup> | |
))} | |
<p className="success">{success}</p> | |
<div className="submit-button"> | |
<Button variant="info" type="submit"> | |
Submit | |
</Button> | |
</div> | |
</Form> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment