import { Form } from '@concrete-form/react-hook-form'
import { useForm } from 'react-hook-form'
const Example = () => {
const form = useForm({...})
return (
<Form form={form} onSubmit={...}>
...
</Form>
)
}| Dependency | Version |
|---|---|
react |
>= 16 |
react-hook-form |
>= 7 |
yarn add @concrete-form/react-hook-form
# or
npm install @concrete-form/react-hook-form| Prop | From | Type | Required | Description |
|---|---|---|---|---|
form |
@concrete-form/react-hook-form |
object | optional | returned by useForm() hook. |
onSubmit |
@concrete-form/react-hook-form |
function | optional | React hook form onsubmit callback. Handled by |
formProps |
@concrete-form/core |
object | optional | props for the <form> element |
noValidate |
@concrete-form/core |
boolean | optional | shorthand formProps for novalidate (default = true) |
{...config} |
@concrete-form/core |
optional | Concrete Form configs (check doc) |
You can :
- Create your form normally with
useForm(recommended) - Let Concrete Form initialize it for you with default settings
If you create the form yourself, don't forget to pass the result of useForm like this :
const form = useForm({ ... })
return <Form form={form} />- render a
<form />element. - render a React hook form
FormProviderso you can useuseFormContext - React hook form will call
onSubmitif provided
- You can use any Concrete form UI element inside
<Form /> - You can use your own controls (check React hook form doc)