react-idle-timer icon indicating copy to clipboard operation
react-idle-timer copied to clipboard

Cross Tab is not working in browser multiple tabs

Open Gagan00001 opened this issue 2 years ago • 5 comments

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).

Gagan00001 avatar Oct 19 '22 12:10 Gagan00001

Can you provide your IdleTimer instantiation?

SupremeTechnopriest avatar Oct 20 '22 20:10 SupremeTechnopriest

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:

  1. Turn on 7 tabs.
  2. Start doing stuff on one tab.
  3. 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.

SupremeTechnopriest avatar Apr 18 '23 21:04 SupremeTechnopriest

The same issue happen in v5.7.2

zhangjianrencai avatar Jul 04 '23 09:07 zhangjianrencai

Any news on this issue?

denjalonso avatar Aug 04 '23 15:08 denjalonso