github react-hook-form/react-hook-form v7.6.0
Version 7.6.0

latest releases: v7.51.4, v7.51.3, v7.51.2...
2 years ago

✨ useForm register absent defaultValues (#5069)

const App = () => {
  const { register, handleSubmit } = useForm({
    defaultValues: {
      test: { firstName: 'bill', lastName: 'luo' }
    }
  })

  const onSubmit = (data) => {
     // missing registered input will be included
     console.log(data) // { test: { firstName: 'bill', lastName: 'luo' } } 
  }
  
  return (
    <form onSubmit={handleSubmit(onSubmit)}>
      <input {...register("test.firstName")} />
      <button />
    </form>
  )
}

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

NewReleases is sending notifications on new releases.