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
I'm trying to make countdown work while I'm switching between components. And I pass the state from redux store with the date, but the counter freezes after a few seconds. What am I doing wrong?
// slicer init state codevarnow=Date.now();
initialState: {now: now,date: now+60000*30,isStarted: false,isPaused: true},// timer component constdateState=useSelector(state=>state.timer.date)constnow=useSelector(state=>state.timer.now)constisStarted=useSelector(state=>state.timer.isStarted)constisPaused=useSelector(state=>state.timer.isPaused)constdispatch=useDispatch();constclockRef=useRef()<Countdownref={clockRef}date={dateState}// trying to set init date from reduxnow={()=>now}// trying to use now same as in redux (it works if I pass Date.now()) intervalDelay={0}autoStart={isStarted}zeroPadTime={2}zeroPadDays={2}precision={2}renderer={renderer}onStart={()=>{dispatch(updateIsStarted(true));dispatch(updateIsPaused(false))}}onPause={()=>{dispatch(updateIsPaused(true));dispatch(updateIsStarted(false))}}onStop={()=>{dispatch(updateIsPaused(true));dispatch(updateIsStarted(false))}}onTick={props=>console.log(props.total)}/>
It's started with 30:00:00, and when I start the timer it goes forward and stops something about at ~30:03:43
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to make countdown work while I'm switching between components. And I pass the state from redux store with the date, but the counter freezes after a few seconds. What am I doing wrong?
It's started with 30:00:00, and when I start the timer it goes forward and stops something about at ~30:03:43
Beta Was this translation helpful? Give feedback.
All reactions