From f2edb0d87c9351a76b07c139d83f0a003dc71a02 Mon Sep 17 00:00:00 2001 From: Nguyen Minh Tuan Date: Thu, 10 Oct 2024 20:13:56 +0700 Subject: [PATCH] Fix #7323: Clear timer in InputNumber component on unmount (#7325) * Fix #7323: Clear timer in InputNumber component on unmount * Refactor: InputNumber use built-in `useUnmountEffect` instead of `useEffect` --- components/lib/inputnumber/InputNumber.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/lib/inputnumber/InputNumber.js b/components/lib/inputnumber/InputNumber.js index 175bedb35a..d59f22acc4 100644 --- a/components/lib/inputnumber/InputNumber.js +++ b/components/lib/inputnumber/InputNumber.js @@ -1,7 +1,7 @@ import * as React from 'react'; import PrimeReact, { PrimeReactContext } from '../api/Api'; import { useHandleStyle } from '../componentbase/ComponentBase'; -import { useMergeProps, useMountEffect, useUpdateEffect } from '../hooks/Hooks'; +import { useMergeProps, useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks'; import { AngleDownIcon } from '../icons/angledown'; import { AngleUpIcon } from '../icons/angleup'; import { InputText } from '../inputtext/InputText'; @@ -1135,6 +1135,10 @@ export const InputNumber = React.memo( ObjectUtils.combinedRefs(inputRef, props.inputRef); }, [inputRef, props.inputRef]); + useUnmountEffect(() => { + clearTimer(); + }); + useMountEffect(() => { constructParser();