Skip to content

Commit 37f6607

Browse files
committed
fix(input): clear timeouts on umount
1 parent fc38e25 commit 37f6607

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/input-otp/src/input.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export const OTPInput = React.forwardRef<HTMLInputElement, OTPInputProps>(
238238

239239
/** Effects */
240240
React.useEffect(() => {
241-
syncTimeouts(() => {
241+
const timeouts = syncTimeouts(() => {
242242
// Forcefully remove :autofill state
243243
inputRef.current?.dispatchEvent(new Event('input'))
244244

@@ -252,6 +252,9 @@ export const OTPInput = React.forwardRef<HTMLInputElement, OTPInputProps>(
252252
inputMetadataRef.current.prev = [s, e, dir]
253253
}
254254
})
255+
return () => {
256+
timeouts.forEach(timeout => clearTimeout(timeout))
257+
}
255258
}, [value, isFocused])
256259

257260
React.useEffect(() => {

0 commit comments

Comments
 (0)