npm react-hook-form 7.57.0-next.0
Version 7.57.0-next.0

latest releases: 7.58.1, 7.58.0, 7.57.0...
one month ago

👀 useWatch new compute props

  • 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 ? data : '';
  },
});

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

NewReleases is sending notifications on new releases.