Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit dd97554

Browse files
authoredNov 2, 2021
Merge pull request #20 from krazibit/fix-oncomplete-callback
fix: use value length to detect completion
2 parents f9b7d6f + bebd427 commit dd97554

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ const ReactInputVerificationCode = ({
149149

150150
React.useEffect(() => {
151151
const stringValue = value.join('');
152-
const isCompleted = !stringValue.includes(placeholder);
152+
const isCompleted = stringValue.length === length;
153153

154154
if (isCompleted) onCompleted(stringValue);
155155
onChange(stringValue);
156-
}, [value]);
156+
}, [value, length]);
157157

158158
React.useEffect(() => {
159159
if (typeof pValue !== 'string') return;

0 commit comments

Comments
 (0)
Please sign in to comment.