Skip to content

Commit

Permalink
Merge pull request stakwork#571 from stakwork/feat/react_tab_state
Browse files Browse the repository at this point in the history
Fixed React Mobx State Across Multiple Tabs
  • Loading branch information
elraphty authored Jul 8, 2024
2 parents b895186 + 9e7aedb commit 7f9040a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/store/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ import { modalsVisibilityStore } from './modals';
}
const hydrate = create({ storage: localStorage });

Promise.all([hydrate('main', mainStore), hydrate('ui', uiStore)]).then(() => {
uiStore.setReady(true);
function hydrateAll() {
Promise.all([hydrate('main', mainStore), hydrate('ui', uiStore)]).then(() => {
uiStore.setReady(true);
});
}
hydrateAll();

document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
hydrateAll();
}
});
})();

Expand Down

0 comments on commit 7f9040a

Please sign in to comment.