-
-
Notifications
You must be signed in to change notification settings - Fork 145
Open
Labels
bugA verified and reproducible bug.A verified and reproducible bug.triageHas not been reviewed yet and should not be worked on.Has not been reviewed yet and should not be worked on.
Description
What happened?
Calling reset within the onIdle makes it take more the amount of the original timeout to Idle. It seems to correct itself after a few iterations.
Reproduction Steps
Reference the below code and it will successfully Idle and the subsequent Idle will take longer to trigger.
import { forEach } from "lodash"
import { Dispatch, SetStateAction, useCallback, useRef } from "react"
import { IIdleTimer, useIdleTimer } from "react-idle-timer"
function useIdle()
{
const idleTimer = useRef<IIdleTimer>()
const onAction = useCallback(() => {
console.log('onAction')
},[])
const onIdle = useCallback(() => {
console.log('onIdle')
onAction()
idleTimer.current?.reset())
},[onAction])
idleTimer.current = useIdleTimer({
timeout: 1000 * 1 * 10,
onIdle: onIdle,
onAction : onAction,
throttle: 1000 * 3
})
return {setNeverTimeout, setHasToken, setShouldExtend}
}
export default useIdleRelevant log output
No response
Screenshots or Additional Context
No response
Module Version
5.7.2
What browsers are you seeing the problem on? Select all that apply.
Chrome, Microsoft Edge
What devices are you seeing the problem on?
Desktop
Verification
- I have checked for existing closed issues and discussions.
Metadata
Metadata
Assignees
Labels
bugA verified and reproducible bug.A verified and reproducible bug.triageHas not been reviewed yet and should not be worked on.Has not been reviewed yet and should not be worked on.