mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
refactor comment components
This commit is contained in:
parent
60da84aad9
commit
eea7095e65
42 changed files with 89 additions and 76 deletions
20
src/components/common/Authorized/index.tsx
Normal file
20
src/components/common/Authorized/index.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import React, { FC } from 'react';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
|
||||
interface IProps {
|
||||
// don't wait for user refetch, trust hydration
|
||||
hydratedOnly?: boolean;
|
||||
}
|
||||
|
||||
const Authorized: FC<IProps> = observer(({ children, hydratedOnly }) => {
|
||||
const { isUser, fetched } = useAuth();
|
||||
|
||||
if (!isUser || (!hydratedOnly && !fetched)) return null;
|
||||
|
||||
return <>{children}</>;
|
||||
});
|
||||
|
||||
export { Authorized };
|
Loading…
Add table
Add a link
Reference in a new issue