Package Exports
- react-idle-timer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-idle-timer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React Idle Timer
React.js port of jQuery.idleTimer with some extras.
Installation
npm install react-idle-timer
Usage
check the examples directory for a working example
import IdleTimer from 'react-idle-timer';
export default React.createClass({
displayName: 'YourApp',
render() {
return (
<IdleTimer
ref="idleTimer"
element={document}
activeAction={this._onActive}
idleAction={this._onIdle}
timeout={this.state.timeout}
format="MM-DD-YYYY HH:MM:ss.SSS">
<h1>All your children</h1>
</IdleTimer>
);
}
});
Documentation
Props
- timeout {Number} - Idle timeout in milliseconds
- events {Array} - Events to bind
- idleAction {Function} - Function to call on idle
- activeAction {Function} - Function to call on active
- element {Object} - Defaults to document, may pass a ref to another element
- format {String} - moment.js format string applied to
lastActiveTime
Methods
- reset() {Void} - Resets the idleTimer
- pause() {Void} - Pauses the idleTimer
- resume() {Void} - Resumes a paused idleTimer
- getRemainingTime() {Number} - Returns the remaining time in milliseconds
- getElapsedTime() {Number} - Returns the elapsed time in milliseconds
- lastActiveTime() {String} - Returns the last active time as a number or a formatted string if the
formatprop is defined - isIdle() {Boolean} - Returns whether or not user is idle
