Skip to content

Not working with React #6

@gatlanticus

Description

@gatlanticus

I want to use localsync in React to log user out of all tabs when they log out of one tab.

When the trigger is called, the action executes in one tab, but the handler is not called in another. Tested in Chrome. I have something like the following:

export class App extends Component {
  componentDidMount(){
    this.globalLogout = localsync('logout', this.syncAction, this.localLogout, {tracing: true});
  }

  syncAction = () => {/*do nothing*/ return;}

  localLogout = () => {console.log("user has been logged out of this tab");}

  logoutUser = () => {
    this.localLogout();
    this.globalLogout.trigger();
  }
}

In the console, I got storagesync#start on for each Chrome tab that I opened. I then got storagesync#trigger > [] on calling logoutUser in one tab, but nothing happens in the other tabs. I expected to get the message "user has been logged out of this tab" on every tab.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions