Skip to content

Commit

Permalink
docs: improve comment by adding example
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannfleurydev committed Sep 12, 2024
1 parent e0d31a2 commit bd18b96
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/form/useWatchToTrigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ import { FieldPath, FieldValues, UseFormReturn } from 'react-hook-form';
* custom issues) will tell you that the `min` should be lower than the default.
* You update the `default` so the new value is 5.5. Without this hook, the
* field `min` will not revalidate. With this hook, if you gave the name, it will.
*
* @example
* // Get the form
* const form = useFormContext<FormType>();
*
* // Subscribe to fields validation
* // If `default` change, `min`, `default` and `max` will validate and trigger
* // error if any.
* useWatchToTrigger({ form, names: ['min', 'default', 'max']})
*/
export const useWatchToTrigger = <
TFieldValues extends FieldValues = FieldValues,
Expand Down

0 comments on commit bd18b96

Please sign in to comment.