title: check user inactivity throughout the component in Reactjs
body: <p>I have react app with several routes rendering several components. How do i check user inactivity for all the pages. If user is inactive in any of the page for more than 5 mins, I want a function to be executed which does some operation, if user does some activities like click, enter etc the inactivity time should be reset back to 5 mins.</p>
  <p>Looked into these answers but wasn't able to do it.</p>
  <p><a href="https://stackoverflow.com/questions/667555/how-to-detect-idle-time-in-javascript-elegantly">How to detect idle time in JavaScript elegantly?</a></p>
  <p><a href="https://stackoverflow.com/questions/40888776/how-to-auto-log-off-when-a-user-is-inactive-in-reactjs">How to auto log off when a user is inactive in ReactJS?</a></p>
  <p>Can it be done using only vanilla Javascript without any packages?</p>
  <p>Thanks in advance !</p>