Files
ncd-fe/packages/pl-fe/src/hooks/useOwnAccount.ts
marcin mikołajczak 966b04fdf0 Call it pl-fe internally
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:41:08 +02:00

25 lines
518 B
TypeScript

import { useCallback } from 'react';
import { makeGetAccount } from 'pl-fe/selectors';
import { useAppSelector } from './useAppSelector';
/** Get the logged-in account from the store, if any. */
const useOwnAccount = () => {
const getAccount = useCallback(makeGetAccount(), []);
const account = useAppSelector((state) => {
const { me } = state;
if (typeof me === 'string') {
return getAccount(state, me);
}
});
return { account: account || undefined };
};
export {
useOwnAccount,
};