File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default function useFieldState({
15
15
} : FieldStateProps ) {
16
16
const [ value , setValue ] = useState ( props . value ) ;
17
17
const [ isFocused , setIsFocused ] = useState ( false ) ;
18
- const [ isValid , setIsValid ] = useState ( true ) ;
18
+ const [ isValid , setIsValid ] = useState < boolean | undefined > ( undefined ) ;
19
19
const [ failingValidatorIndex , setFailingValidatorIndex ] = useState < number | undefined > ( undefined ) ;
20
20
21
21
useEffect ( ( ) => {
@@ -37,7 +37,9 @@ export default function useFieldState({
37
37
} , [ props . value , validateOnChange ] ) ;
38
38
39
39
useDidUpdate ( ( ) => {
40
- onChangeValidity ?.( isValid ) ;
40
+ if ( ! _ . isUndefined ( isValid ) ) {
41
+ onChangeValidity ?.( isValid ) ;
42
+ }
41
43
} , [ isValid ] ) ;
42
44
43
45
const checkValidity = useCallback ( ( valueToValidate = value ) => {
@@ -86,7 +88,7 @@ export default function useFieldState({
86
88
return {
87
89
value,
88
90
hasValue : ! _ . isEmpty ( value ) ,
89
- isValid : validationMessage && ! validate ? false : isValid ,
91
+ isValid : validationMessage && ! validate ? false : isValid ?? true ,
90
92
isFocused,
91
93
failingValidatorIndex
92
94
} ;
You can’t perform that action at this time.
0 commit comments