1
1
import { useEffect , useRef } from 'react' ;
2
2
import { Apis , GlobalProps } from 'react-form-simple/types/form' ;
3
- import { useController } from 'react-form-simple/use/useController' ;
4
3
import useForceUpdate from 'react-form-simple/use/useForceUpdate' ;
5
4
import { FormUtil } from 'react-form-simple/utils/FormUtil' ;
6
5
import {
@@ -62,9 +61,7 @@ export function useFormItemContentController(
62
61
63
62
formUtil . replace ( { model : modelValue . current } ) ;
64
63
65
- const status = useController ( { isError : false } ) ;
66
-
67
- const { isError } = status ;
64
+ const isError = useRef ( false ) ;
68
65
69
66
const isInitSubscribeEvent = useRef ( true ) ;
70
67
@@ -73,7 +70,10 @@ export function useFormItemContentController(
73
70
methods . set ( value ) ;
74
71
} ) ;
75
72
subscribe . on ( 'onErr' , ( value ) => {
76
- status . isError = isMeaningful ( value ) ;
73
+ if ( isError . current !== isMeaningful ( value ) ) {
74
+ forceUpdate ( false ) ;
75
+ }
76
+ isError . current = isMeaningful ( value ) ;
77
77
} ) ;
78
78
isInitSubscribeEvent . current = false ;
79
79
}
@@ -82,14 +82,14 @@ export function useFormItemContentController(
82
82
if ( bindId !== preBindId . current ) {
83
83
modelValue . current = convertStringToObject ( bindId , initialValue ) ;
84
84
preBindId . current = bindId ;
85
- forceUpdate ( false )
85
+ forceUpdate ( false ) ;
86
86
}
87
87
} , [ bindId ] ) ;
88
88
89
89
const methods = {
90
90
set ( value : any ) {
91
91
updateProxyValue ( modelValue . current , preBindId . current as string , value ) ;
92
- forceUpdate ( false )
92
+ forceUpdate ( false ) ;
93
93
} ,
94
94
} ;
95
95
@@ -112,7 +112,7 @@ export function useFormItemContentController(
112
112
value,
113
113
checked : Boolean ( value ) ,
114
114
} ,
115
- isError,
115
+ isError : isError . current ,
116
116
...apis ,
117
117
} ) || null ;
118
118
0 commit comments