New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@greenlabs/ppx-rhf

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@greenlabs/ppx-rhf

ReScript PPX which generates the bindings for react-hook-form

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
383
increased by13.31%
Maintainers
0
Weekly downloads
 
Created
Source

PPX react hook form

A ReScript PPX for the React Hook Form bindings

Example

@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)

  <form onSubmit={handleSubmit(onSubmit)}>
    <input {...register(Example)} defaultValue="test" />
    <input {...register(ExampleRequired, ~options={required: true})} />
    {formState.errors.exampleRequired->Belt.Option.isSome
      ? <span> {"This field is required"->React.string} </span>
      : React.null}
    <input type_="submit" />
  </form>
}

More examples

Getting Started

Install

The ppx-rhf supports the uncurried mode only.

pnpm add -D @greenlabs/ppx-rhf
// rescript.json or bsconfig.json

"bs-dependencies": [
  "@greenlabs/ppx-rhf"
],
"ppx-flags": [
  ...,
  "@greenlabs/ppx-rhf/ppx"
],

API

Read more

Keywords

FAQs

Package last updated on 25 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc