github react-hook-form/react-hook-form v6.0.0-rc.5
Version 6.0.0-rc.5

latest releases: v7.51.3, v7.51.2, v7.51.1...
3 years ago

⚡ feature/set value should not set dirty to true and give users option

setValue

Reason

The current API is confusing with support both name as string and array of values. In addition, programmatically set a field should give users the option to set dirty, we shouldn't set dirty to true when user setValue programmatically by default.

setValue(fieldName, values, config)

setValue('test', 'value', { shouldValidate: false, shouldDirty: false })


💈 fix/improve setError & clearError (#1907)

setError

setError will focus one error at a time and remove confusing set multiple errors, behavior change.

  • setError will persis an error if it's not part of the form, which requires manual remove with clearError
  • setError error will be removed by validation rules, rules always take over errors

Reason

should focus an error at a time just like the name suggested, refine the API and remove multiple errors set.

- setError('test', 'test', 'test')
+ setErrror('test', { type: 'test', message: 'bill'})

clearError

Rename to clearErrors

Reason

This function allow remove multiple errors, so make sense to rename it to clearErrors

- clearError()
+ clearErrors()

👍🏻 fix/get values (#1913)

getValues

getValues will no longer return the default value.

Reason

getValues should use to get the current form values, it doesn't make sense to get default values.


👍 improve ControllerProps type (#1872)

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

NewReleases is sending notifications on new releases.