mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed auth hydration
This commit is contained in:
parent
d9feff085a
commit
e90f8b6888
3 changed files with 14 additions and 3 deletions
|
@ -1,10 +1,13 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
import { Store } from '~/store';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
|
||||
export const StoreContext = createContext<Store>(new Store());
|
||||
|
||||
export const StoreContextProvider: FC<{ store: Store }> = ({ children, store }) => {
|
||||
export const StoreContextProvider: FC<{ store: Store }> = observer(({ children, store }) => {
|
||||
if (!store.isHydrated) return null;
|
||||
|
||||
return <StoreContext.Provider value={store}>{children}</StoreContext.Provider>;
|
||||
};
|
||||
});
|
||||
|
||||
export const useStore = () => useContext(StoreContext);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue