Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/green-labs/ppx_react_hook_form
ReScript PPX for the react hook form bindings
https://github.com/green-labs/ppx_react_hook_form
Last synced: about 1 month ago
JSON representation
ReScript PPX for the react hook form bindings
- Host: GitHub
- URL: https://github.com/green-labs/ppx_react_hook_form
- Owner: green-labs
- Created: 2023-12-05T06:44:19.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-21T07:27:15.000Z (2 months ago)
- Last Synced: 2024-10-23T01:33:28.346Z (2 months ago)
- Language: OCaml
- Size: 211 KB
- Stars: 9
- Watchers: 6
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# PPX react hook form
A ReScript PPX for the [React Hook Form](https://react-hook-form.com) bindings
## Example
```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))
let exampleFieldState = getFieldState(Example, formState)
Js.log(exampleFieldState)
Js.log(setValue)
{formState.errors.exampleRequired->Belt.Option.isSome
? {"This field is required"->React.string}
: React.null}
}
```[More examples](doc/examples.md)
## Getting Started
### Install
**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"
],
```## API
[Read more](/doc/api.md)