Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to detect the origin tab of an update? #14

Open
hcharley opened this issue Jun 29, 2019 · 1 comment
Open

Is it possible to detect the origin tab of an update? #14

hcharley opened this issue Jun 29, 2019 · 1 comment

Comments

@hcharley
Copy link

For example:

const useOpts = createPersistedState('key');

const Comp = props => {
  const [opts, setOpts] = useOpts({
    show: false
  });
  useEffect(() => {
    if (opts.show) {
      console.log('Show');
    } else {
      console.log('Hide');
    }
    if (opts._originDoc === document) {
      console.log('Origin was from this tab');
    } else {
      console.log('Origin of update was from another tab');
    }
  }, [opts.show])
  return (
    <>Test</>
  );
}
@revelcw
Copy link

revelcw commented Nov 9, 2019

Yes, there is a way to find out if it came from this tab or another but we don't have the code to pass it back to you, maybe if you tell me your use-case we could change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants