You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When resetting the timer it appears to reset correctly when tracking remaining time, however the timeout value doubles before onIdle is called again
Reproduction Steps
1. set a timeout for 10 seconds
2. increase a count var every time idle is called
3. reset timer
4. After first 10 seconds counter increase by 1 as expected
5. next time counter does not increase again for 20 seconds
6. New timeout appears to have doubled
import{useIdleTimer}from"react-idle-timer";import{useEffect,useState}from"react";exportdefaultfunctionApp(){const[remaining,setRemaining]=useState(0);const[count,setCount]=useState(0);// correct behaviour first time onIdle is called// after reset onIdle is called every 20 seconds instead of 10constonIdle=()=>{setCount((prev)=>(prev+=1));reset();};const{ reset, getRemainingTime }=useIdleTimer({
onIdle,timeout: 10_000,throttle: 500,});useEffect(()=>{constinterval=setInterval(()=>{setRemaining(Math.ceil(getRemainingTime()/1000));},500);return()=>{clearInterval(interval);};});return(<divclassName="App"><h1>Reset</h1><h2>Time Remaining {remaining}</h2><h2>Count: {count}</h2></div>);}
Module Version
5.7.2
What browsers are you seeing the problem on? Select all that apply.
Chrome
What devices are you seeing the problem on?
Desktop
Verification
I have checked for existing closed issues and discussions.
The text was updated successfully, but these errors were encountered:
Is this issue fixed? I have the latest version and calling start/reset sill doubles the timeout value. In my case, I'm reseting the timer in onIdle if some condition is false. When logging the getRemainingTime on a timer of 5s, it goes from 5 to 1, then if the start is called, the log goes again from 5 to 1 and instead of idling out, the log goes again from 5 to 1.
What happened?
When resetting the timer it appears to reset correctly when tracking remaining time, however the timeout value doubles before onIdle is called again
Reproduction Steps
Relevant log output
No response
Screenshots or Additional Context
sandbox
Module Version
5.7.2
What browsers are you seeing the problem on? Select all that apply.
Chrome
What devices are you seeing the problem on?
Desktop
Verification
The text was updated successfully, but these errors were encountered: