We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a808b4e commit 3b6f13fCopy full SHA for 3b6f13f
src/forms/helpers/useFormControl.js
@@ -1,13 +1,17 @@
1
import { useContext, useCallback } from 'react';
2
-import { isEmptyStringLike, isBoolean } from 'js-var-type';
+import { isEmptyStringLike, isBoolean, isFunction } from 'js-var-type';
3
import { FormContext } from './form-helpers';
4
import { toDatetimeLocal, fromDatetimeLocal } from '../../utils/formatters';
5
6
-export function useFormControl(name, type) {
+export function useFormControl(name, type, hooks = { afterChange: () => {} }) {
7
const formState = useContext(FormContext);
8
9
function setValue(value) {
10
formState.update(name, value);
11
+
12
+ if (isFunction(hooks.afterChange)) {
13
+ hooks.afterChange(value);
14
+ }
15
}
16
17
const register = useCallback(
0 commit comments