Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit 0a32a10

Browse files
authored
fix: infinite rendering when passing form render props (#555)
1 parent 8e09afe commit 0a32a10

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/hooks/useFormField.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ export const useFormField = <
3636
minDate,
3737
}: UseFieldConfig<FieldValue, InputValue> & ValidatorProps,
3838
) => {
39+
const serializedRegex = useMemo(() => regex?.toString(), [regex])
40+
3941
const validators = useMemo(
4042
() =>
4143
pickValidators<FieldValue>({
@@ -48,7 +50,17 @@ export const useFormField = <
4850
regex,
4951
required,
5052
}),
51-
[max, maxLength, min, minLength, regex, required, maxDate, minDate],
53+
// eslint-disable-next-line react-hooks/exhaustive-deps
54+
[
55+
max,
56+
maxLength,
57+
min,
58+
minLength,
59+
required,
60+
serializedRegex,
61+
maxDate,
62+
minDate,
63+
],
5264
)
5365

5466
const validateFn = useValidation({ validate, validators })

0 commit comments

Comments
 (0)