react-idle-timer
react-idle-timer copied to clipboard
Cross Tab is not working in browser multiple tabs
I am opening a page in the second tab, loggedUser data will be shared using localStorage, here I'm actively using the page. but the first tab gets idle and when the duration exceeds the first tab will be loggedOut by clearing the localStorage, the user who uses second tab actively will be forced to logout, since there is no loggedUser data (localStorage).
Can you provide your IdleTimer instantiation?
I have same issue with 5.6.0
version.
This is my code
import React from 'react';
import { useIdleTimer } from 'react-idle-timer';
import * as User from 'modules/user';
import * as Company from 'modules/company';
import useUserType from 'helpers/useUserType';
const LogoutTimer = () => {
const { isDeveloper, isInvestor } = useUserType();
const onIdle = () => {
if (isDeveloper()) {
Company.logout();
return;
}
if (isInvestor()) {
User.logout();
return;
}
};
useIdleTimer({
onIdle,
timeout: 30 * 60 * 1000, // 30 minutes
crossTab: true,
});
return <> </>;
};
export default LogoutTimer;
Steps to reproduce:
- Turn on 7 tabs.
- Start doing stuff on one tab.
- After 30 minutes one of those 6 other tabs will log me out, but I am active in my main tab.
Expected result: I should not be logged out. Actual result: I'm being logged out.
Update: I downgraded to 5.3.0 and it works without this issue. Don't know why.
I will look into this.
The same issue happen in v5.7.2
Any news on this issue?