I want to navigate to /oauth2/token when the user remains idle for 10 seconds,but in my code after 10 seconds its not navigating to /oauth2/token
below is my code:
export default function Timeout(){
const idleTimerRef = useRef(null);
const [isUserIdle, setIsUserIdle] = useState(false);
const userIdle = (state) => {
setIsUserIdle(state);
};
return (
<div className="App">
<IdleTimer
ref={idleTimerRef}
timeout={10000}
onIdle={() => userIdle(true)}
onActive={() => userIdle(false)}
></IdleTimer>
{isUserIdle ? <Redirect to='/oauth2/token'/> : <Home />}
)}
I would use the hooks: useEffect and useHistory from router-dom.
Dont forget to import useHistory and useEffect