File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -11,14 +11,16 @@ const KEY_CODE = {
1111
1212type Props = {
1313 length ?: number ;
14- onChange : ( data : string ) => any ;
14+ onChange ?: ( data : string ) => any ;
15+ onCompleted ?: ( data : string ) => any ;
1516 placeholder ?: string ;
1617 value ?: string ;
1718} ;
1819
1920const ReactInputVerificationCode = ( {
2021 length = 4 ,
21- onChange,
22+ onChange = ( ) => { } ,
23+ onCompleted = ( ) => { } ,
2224 placeholder = '·' ,
2325 value : pValue ,
2426} : Props ) => {
@@ -137,7 +139,11 @@ const ReactInputVerificationCode = ({
137139 } , [ ] ) ;
138140
139141 React . useEffect ( ( ) => {
140- onChange ( value . join ( '' ) ) ;
142+ const stringValue = value . join ( '' ) ;
143+ const isCompleted = ! stringValue . includes ( placeholder ) ;
144+
145+ if ( isCompleted ) onCompleted ( stringValue ) ;
146+ onChange ( stringValue ) ;
141147 } , [ value ] ) ;
142148
143149 React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments