Skip to content

Commit

Permalink
[@mantine/form] Add useCallback wrapper to form.resetDirty (#7029)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-dandrea authored Nov 7, 2024
1 parent 96f789f commit a58f00b
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ export function useFormStatus<Values extends Record<string, any>>({

const resetTouched: ResetStatus = useCallback(() => setTouched({}), []);

const resetDirty: ResetDirty<Values> = (values) => {
const resetDirty: ResetDirty<Values> = useCallback((values) => {
const newSnapshot = values
? { ...values, ...$values.refValues.current }
: $values.refValues.current;
$values.setValuesSnapshot(newSnapshot);
setDirty({});
};
}, []);

const setFieldTouched: SetFieldTouched<Values> = useCallback((path, touched) => {
setTouched((currentTouched) => {
Expand Down

0 comments on commit a58f00b

Please sign in to comment.