score:1

Accepted answer
class useidle extends component() {
constructor() {
  super(props)
  this.state = {
    isidle: false
  }
}
componentdidmount() {
    this.activitydetector = createactivitydetector(time)
    this.activitydetector.on('idle', () => this.setstate({isidle: true}))
    this.activitydetector.on('active', () => this.setstate({isidle: true}))
}

componentwillunmount() {
this.activitydetector.stop()
}

render(){
  return this.state.isidle;
 }
}

Related Query

More Query from same tag