Skip to content

Commit 18d4bd4

Browse files
author
Damian Sznajder
committed
feat: default value to support OTP autofill
1 parent 2b9ee74 commit 18d4bd4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/index.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ const OtpInputs = forwardRef<OtpInputsRef, Props>(
8787
hasKeySupport: Platform.OS === 'ios',
8888
}));
8989

90+
useEffect(() => {
91+
if (defaultValue) {
92+
dispatch({
93+
type: 'setOtpCode',
94+
payload: { numberOfInputs, code: defaultValue },
95+
});
96+
}
97+
}, [defaultValue, numberOfInputs]);
98+
9099
useEffect(() => {
91100
dispatch({ type: 'setHandleChange', payload: handleChange });
92101
}, [handleChange]);

0 commit comments

Comments
 (0)