Closed s-z-s closed 2 years ago
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:
const handleActivity = (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
}
}
Closed for inactivity.
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?