3 ms·
Im a new react developer and it's extra work figuring out how I'd update the page from which you created the new tab without replacing it to trigger a state cha
by afarviral 4y ago
Im a new react developer and it's extra work figuring out how I'd update the page from which you created the new tab without replacing it to trigger a state change. In the case of sites that render data synced to a datastore. Using a timer, sure, but thats not wildly efficient. There must be ways, they're just an extra consideration.
- afarviral 4y agoNote: Coming from someone who hates when middle click doesn't open a new tab... so I get why you care.
- amatecha 4y agolinks that go to other "pages" (even just conceptually) should get their own route so you can link to them directly. you can use something like react-router to do this, and it's very easy to extract the active route and know what view to render. or if I'm totally off the mark, maybe I misunderstood what you mean :)
- runarberg 4y agoYou can sync localstorage and sessionstorage between tabs, you only have to listen to the right events. I haven’t used indexeddb much, but I’d be surprised if that doesn’t sync between tabs as well. If you are saving all the state in memory—which I think is the default for most popular frameworks—then you’ll have to do something more clever. If you have a backend server as a single source of truth, then you should probably be using websockets if it is vitally important that your users get real updates of new data. I’m sure there are popular react libraries that will handle each of these cases. It is extra work for sure, but usability improvements usually are, and if you know what you are doing, this will not cost that much extra in maintenance.
- nextaccountic 4y agoI don't understand.. opening on a new tab should do exactly the same as opening a blank tab, typing the address and pressing enter In particular it shouldn't change the original page at all, that's the whole point! Now, if the original page is the kind that updates in real time (due to accesses from other tabs or even from other machines), just use a web socket!