ReScript PPX which generates the bindings for react-hook-form
npm install @greenlabs/ppx-rhfA ReScript PPX for the React Hook Form bindings
``res
@rhf
type inputs = {
example?: string,
exampleRequired: string,
}
@react.component
let default = () => {
let {register, handleSubmit, watch, formState, getFieldState, setValue} = useFormOfInputs()
let onSubmit = (data: inputs) => Js.log(data)
Js.log(watch(Example))
Js.log(getValues(Example))
let exampleFieldState = getFieldState(Example, formState)
Js.log(exampleFieldState)
Js.log(setValue)
Getting Started
$3
The ppx-rhf supports the uncurried mode only.
`sh
pnpm add -D @greenlabs/ppx-rhf
``json
// rescript.json or bsconfig.json"bs-dependencies": [
"@greenlabs/ppx-rhf"
],
"ppx-flags": [
...,
"@greenlabs/ppx-rhf/ppx"
],
``