React Idle Timer
Welcome to the all new IdleTimer! The documentation has moved to https://idletimer.dev. There you can find everything you need to get started using and contributing to IdleTimer.
Activity detection for React.js
Welcome to the all new IdleTimer! The documentation has moved to https://idletimer.dev. There you can find everything you need to get started using and contributing to IdleTimer.
disabled
property would not immediately disable the timer.estrella
with esbuild
and update build chain.The project has switched IDEs from VS Code to WebStorm. The
.vscode
directory has been replaced with.idea
.
null
or undefined
as the value for the element
property to enable easier integration with refs.promptBeforeIdle
is greater than or equal to timeout
. #342IIdleTimer
interface as the second parameter to callback methods. #339onPrompt
would be emitted instead of onIdle
after timeout
is exceeded when devices wake from sleep. #172onMessage
was being called with an old function reference. #328IdleTimerComponent
generic typescript types.null
.isLastActiveTab
method. #294getActiveTime
and getIdleTime
methods. #301onPresenceChange
event handler. #319promptTimeout
in favor of promptBeforeIdle
. #318activate
method. #319onActive
was called on every action when syncTimers
was set. #320componentDidMount
on withIdleTimer higher order component. #276onAction
callbacks. #127getRemainingTime()
.createMocks()
.reset
was not resetting the start time affecting getTotalActiveTime()
. #272crossTab
is enabled causing bad performance when many tabs are open. #247reset
method now respects startManually
property. It will no longer automatically call onActive
.DEFAULT_EVENTS
for easy extension of events. #260getRemainingTime
method now always returns the time to idle instead of time to prompt and then time to idle. #256onAction
callbacks will automatically be cancelled on idle. #255name
property to support multiple instances when crossTab
is enabled.Omit
over utility-types Subtract
. Fixes missing dependency error.withIdleTimer
.withIdleTimer
.Due to popular request, Leader Election has returned in version 5.1.0. While the old implementation was incompatible with v5, this new implementation is compatible. A new property
leaderElection
is exposed to enable the feature. The major difference between the v4 and v5 implementation is that in v5 events are not isolated to your leader tab automatically. You will need to call theisLeader
method inside your event handlers. See the docs for more information.
Version 5 is a complete, from scratch, typescript rewrite. A lot of effort went into this release. If you find this package useful and have the means, please consider a small donation!
immediateEvents
property.withIdleTimer
.IdleTimerProvider
.syncTimers
property.crossTab
from the ground up. The new implementation is much smaller and more efficient.getTotalActiveTime
returning negative value.capture
property.passive
property.emitOnAllTabs
property.isLeader
method.ref
optional in typedef.ref
to TypeScript definitions.onActive
and onIdle
event handlers in conjunction with cross tab event reconciliation.emitOnAllTabs
is set to true
, start
, reset
, pause
and resume
will be called on all tabs.reset
will now automatically fire onActive
while calling start
will not. Otherwise these two methods are functionally equivalent.localStorage
method would not call idle
if there wasn't any user activity on the page.TabManager
would not deregister itself when the tab was closed if it was not the leader tab.isLeader()
method that returns a boolean indicating whether or not the current tab is the lead orchestrator for cross tab reconciliation.startManually
configuration option to enable starting of the timer and activity detection manually. An alias to reset()
called start()
is also exposed to keep the code more semantic. If startManually
is set to true
, the IdleTimer
component and useIdleTimer
hook wont start until reset()
or start()
are called.resume
or pause
from inside a useEffect
will now properly bind and unbind events.onActive
if the user is idle.getLastIdleTime
to component scope making the method callable.getTotalActiveTime
and getTotalIdleTime
to component scope making the methods callable.getLastIdleTime
and getTotalIdleTime
methods.getTotalActiveTime
to be accurate in more scenarios.getTotalActiveTime
method. Returns the total time in milliseconds the user was active.let
and const
. Re-implement babel to transpile to var
.debounce
and throttle
were not applied to onAction
.useIdleTimer
hook implementation.eventsThrottle
to reduce cpu using on events that can spam the event handler. Defaults to 200ms.visibilitychange
event to default events. #98stopOnIdle
set. #96getRemainingTime()
.reset()
was not resetting getRemainingTime()
.componentWillMount
is deprecated. Moved logic to componentDidMount
.Events are unbound when:
stopOnIdle
is set to true
and the user goes idlepause()
is calledEvents are bound when:
reset()
is calledresume()
is calledstopOnIdle
will now keep IdleTimer
in idle state until reset()
is called.stopOnIdle
logic was being applied to active state.onIdle
event was not firing when stopOnIdle
is setstopOnIdle
defaults to false
. Setting to true
will prevent user activity from restarting the IdleTimer
once it has gone idle. This useful if you want to do some custom async stuff before the IdleTimer
gets restarted. In order to restart the IdleTimer
call reset()
on your ref.onActive
which enables reporting of all user activity from IdleTimer
. The built in debounce
or throttle
properties will help increase performance if you are using the onActive
event. By default debounce
and throttle
are off. Only one can be enabled at a time.debounce
defaults to 0. Set the onActive
debounce delay in milliseconds. The throttle
property cannot be set if this property is set.throttle
defaults to 0. Set the onActive
throttle delay in milliseconds. The debounce
property cannot be set if this property is set.startOnMount
to false
starts IdleTimer in the wrong state.startOnMount
to false
starts IdleTimer in the wrong state.Version 4.0 contains a rewrite of the build system and a refactor of the source code for IdleTimer. After accepting many pull requests, the projects code style was destroyed, so some forced styling was added and PRs that don't respect this style will not be accepted. Contribution guide now on the README.
startOnLoad
has been renamed to startOnMount
to make more sense in a react context.activeAction
has been renamed to onActive
.idleAction
has been renamed to onIdle
.true
, bind events with passive mode enabled.true
, bind events with capture mode enabled.onActive
callback functions.Dropped support for date formatting in version 3. IdleTimer returns raw date objects and you can use which ever library you like to format it. If you would like to continue using the built in formatter, stick with version 2.
Initial release.