File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
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 ,
2122 onChange,
23+ onCompleted,
2224 placeholder = '·' ,
2325 value : pValue ,
2426} : Props ) => {
@@ -137,7 +139,15 @@ const ReactInputVerificationCode = ({
137139 } , [ ] ) ;
138140
139141 React . useEffect ( ( ) => {
140- onChange ( value . join ( '' ) ) ;
142+ const stringValue = value . join ( '' )
143+
144+ if ( typeof onChange === "function" ) {
145+ onChange ( stringValue ) ;
146+ }
147+
148+ if ( ! stringValue . includes ( placeholder ) && typeof onCompleted === "function" ) {
149+ onCompleted ( stringValue )
150+ }
141151 } , [ value ] ) ;
142152
143153 React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments