7

We are opening new window tab which contains the userList based on the selected userId from a list. I open the new window like this:

this.props.getVisitDetails(this.props.userId)
var win = window.open('./requisition','_blank');
win.onload = function() { this.document.title = windowTittle; }
win.focus();
this.state.oldWindow.push(win);

Here I am getting userId from the Redux store. The problem is that if I am opening more than one window tab then userId on every window tab will have the same userId and when you will click refresh then all window tabs will have the same data. So my question is how can I maintain a separate state for each window tab?

Note: all browser tab all sharing same stored state that we saved using createstore method,so in my case visitid will be updated on every row click which will open browser's new tab. This is how the data is "shared"

8
  • 1
    As much I understand, you are opening a new browser tab. I don't think two tabs can share/have same state. Infact, browser tabs don't share data. Commented Jan 19, 2017 at 15:19
  • Yes all browser tab all sharing same stored state that we saved using createstore method,so in my case visitid will be updated on every row click which will open browser's new tab. Commented Jan 19, 2017 at 15:25
  • I dont think that is possible. Redux state cant be shared across browser tabs Commented Jan 19, 2017 at 15:27
  • 1
    You can download redux debugger for crome and check Commented Jan 19, 2017 at 15:36
  • You don't have explicit control over browser tabs. You can however manipulate your URL so that your component would load different data accordingly. Commented Jan 20, 2017 at 0:21

1 Answer 1

2

Your store is not shared across multiple tabs, So every time you open new tab your whole application gets loaded again along with initialization of fresh store. So, In your case simple solution will be to open new tab with URL containing userId as query param(window.open('./requisition?userId=${userId}','_blank');). Such that you will be able to maintain separate userId in different browser tabs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.