我需要知道是否有REACT JS或HTML5中的任何API,当用户处于非活动状态时,它提供了auto-log关闭的功能。我的代码在下面我不知道什么是错误它给我的错误startTimer不是定义和不必要的binding.Please告诉我,我错了如何在用户在ReactJS中处于非活动状态时自动注销?
import React from 'react';
import ReactDOM from 'react-dom';
import './App.css';
class Toogle extends React.Component {
constructor(props) {
super(props);
//step 1
this.handleClick = this.handleClick.bind(this);
this.startTimer=this.startTimer.bind(this)
}
handleClick() {
console.log('Button is clicked');
// clearTimeout(timeoutTimer);
startTimer() {
var timeoutTimer = setTimeout(function() {
window.location.href = '#/security/logout';
}.bind(this), 1000);
}
}
render() {
return (<div onMouseMove={this.handleClick}>Move the cursor over me</div>);
}
}
ReactDOM.render(
<Toogle />,
document.getElementById('root')
);
非常广泛的问题..不是真的太值得。您必须自己编写这些功能或查找认证软件包。 –