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
We're using react-idle-timer with an external (server-side) session manager. Because of this, I have to update timeout and promptBeforeIdle after I sync with that service, which I do inside the timer's onPresenceChange handler.
The problem is, I need to derive all of my session management component's state from the time returned from our session management service, and that means promptBeforeIdle needs to potentially change along with timeout.
When I get to the point of entering a prompt or idle state, I can get into a situation where the idle timer throws an error, if timeout and promptBeforeIdle both end up being 0. The rule is that promptBeforeIdle has to be less thantimeout. When it errors (because I don't have an error boundary, currently), my entire UI goes blank.
I tried getting around this by setting promptBeforeIdle to undefined when I don't want to be resetting it to a positive value (or 0, for reasons just cited, but internally, that's the same as setting it to 0 (it's the default), and I get the same error.
My only workaround is to set it to a negative number, which seems hacky.
Should there be a way around this? Should that prop default to 0 if you set it to undefined (or don't set it at all)?
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
-
Hello, and thanks for this package!
We're using react-idle-timer with an external (server-side) session manager. Because of this, I have to update
timeout
andpromptBeforeIdle
after I sync with that service, which I do inside the timer'sonPresenceChange
handler.The problem is, I need to derive all of my session management component's state from the time returned from our session management service, and that means
promptBeforeIdle
needs to potentially change along withtimeout
.When I get to the point of entering a prompt or idle state, I can get into a situation where the idle timer throws an error, if
timeout
andpromptBeforeIdle
both end up being0
. The rule is thatpromptBeforeIdle
has to be less thantimeout
. When it errors (because I don't have an error boundary, currently), my entire UI goes blank.I tried getting around this by setting
promptBeforeIdle
toundefined
when I don't want to be resetting it to a positive value (or0
, for reasons just cited, but internally, that's the same as setting it to0
(it's the default), and I get the same error.My only workaround is to set it to a negative number, which seems hacky.
Should there be a way around this? Should that prop default to
0
if you set it toundefined
(or don't set it at all)?Beta Was this translation helpful? Give feedback.
All reactions