yarn react-hook-form 7.61.0
Version 7.61.0

latest releases: 7.62.0, 7.61.1
one month ago

🧮 feat: compute prop for useWatch subscription (#12503)

  • subscribe to the entire form but only return updated value with certain condition
type FormValue = {
  test: string;
}

const watchedValue = useWatch({
  control: methods.control,
  compute: (data: FormValue) => {
    if (data.test?.length) {
      return data.test;
    }

    return '';
  },
});
  • subscribe to a specific form value state
type FormValue = {
  test: string;
}

const watchedValue = useWatch({
  control: methods.control,
  name: 'test',
  compute: (data: string) => {
      return data.length > 3 ? data : '';
  },
});

👨‍🔧 trigger watch callbacks in response to value changes only (#12945)
🙏 track name with setValue subscription callbacks (#12946)
⌨️ fix: watch return type based on defaultValue (#12896)
🐞 fix #12959 subscribe with latest defaultValues #12961
🐞 fix: handle explicit "multipart/form-data" encType in Form Component (#12948)
🐞 fix(build): Remove React wildcard import to resolve ESM build issues (#12942)
🦭 chore: improve exclude patterns (#12935)
🐿️ chore: remove unused omit function (#12958)

Big thanks to @joshkel for helping with some of the subscription bugs! and also @kamja44, @mrazauskas, @codepunkt, @afontcu and @rururux

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

NewReleases is sending notifications on new releases.