我需要知道是否有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')
);
非常廣泛的問題..不是真的太值得。您必須自己編寫這些功能或查找認證軟件包。 –