npm react-hook-form 7.43.0
Version 7.43.0

latest releases: 7.53.2, 7.53.1, 7.53.0...
21 months ago

🌏 feature: support global error type #9746

const onSubmit = () => {
  const response = await fetch(...)
  if (response.statusCode > 200) {
      setError('root.serverError', { 
        type: response.statusCode,
      })
  }
}

const onClick = () => {
  setError('root.random', { 
    type: 'random', 
  })
}

return (
  <>
    {errors.root.serverError.type === 400 && <p>server response message</p>}
    <p>{errors.root?.serverError?.message}</p>
    <p>{errors.root?.random?.message}</p>
  </>
)

🪜 fix set values for controlled components (#9780)

const { control } = useForm({ values: { test: '' } })
<Controller name="test" /> // no longer throw react warning for uncontrolled become controlled.

🚓 stronger typing to document non-spec attribute uses (#9809)

register('number', {
  valueAsNumber: true,
  pattern: /[1-4]/g // ❌ type error
})

🏋🏻‍♀️ reduce package size (#9778)
🧧 reduce unknown and any (#9816)

Don't miss a new react-hook-form release

NewReleases is sending notifications on new releases.