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
But length is returned 0 when the function is called during first inactivity when there is an item in the cart. If the same function is called on a button press, correct value is returned.
What should I do to get correct value everytime?
The text was updated successfully, but these errors were encountered:
Hi, at first glance it seems that you're updating the state twice while handling your activity, which may cause odd behaviours.
Try shifting line 2 down like this:
consthandleActivity=(isActive: boolean)=>{console.log('active: '+isActive);if(!isActive&&cartItems.length==0){// update the state once such that state.isActive = isActive and a logout is performed}}
I'm trying to logout user after sometime when there is no item in cart (stored in redux) in my kiosk type application.
But length is returned 0 when the function is called during first inactivity when there is an item in the cart. If the same function is called on a button press, correct value is returned.
What should I do to get correct value everytime?
The text was updated successfully, but these errors were encountered: