File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 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({
1515} : FieldStateProps ) {
1616 const [ value , setValue ] = useState ( props . value ) ;
1717 const [ isFocused , setIsFocused ] = useState ( false ) ;
18- const [ isValid , setIsValid ] = useState ( true ) ;
18+ const [ isValid , setIsValid ] = useState < boolean | undefined > ( undefined ) ;
1919 const [ failingValidatorIndex , setFailingValidatorIndex ] = useState < number | undefined > ( undefined ) ;
2020
2121 useEffect ( ( ) => {
@@ -37,7 +37,9 @@ export default function useFieldState({
3737 } , [ props . value , validateOnChange ] ) ;
3838
3939 useDidUpdate ( ( ) => {
40- onChangeValidity ?.( isValid ) ;
40+ if ( ! _ . isUndefined ( isValid ) ) {
41+ onChangeValidity ?.( isValid ) ;
42+ }
4143 } , [ isValid ] ) ;
4244
4345 const checkValidity = useCallback ( ( valueToValidate = value ) => {
@@ -86,7 +88,7 @@ export default function useFieldState({
8688 return {
8789 value,
8890 hasValue : ! _ . isEmpty ( value ) ,
89- isValid : validationMessage && ! validate ? false : isValid ,
91+ isValid : validationMessage && ! validate ? false : isValid ?? true ,
9092 isFocused,
9193 failingValidatorIndex
9294 } ;
You can’t perform that action at this time.
0 commit comments