fix(core): rerender (#4988)

This commit is contained in:
EYHN
2023-11-20 17:32:40 +08:00
committed by GitHub
parent c127d449a1
commit 899e46b1fa

View File

@@ -2,7 +2,7 @@ import { type User } from '@affine/component/auth-components';
import type { DefaultSession, Session } from 'next-auth'; import type { DefaultSession, Session } from 'next-auth';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports // eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { getSession, useSession } from 'next-auth/react'; import { getSession, useSession } from 'next-auth/react';
import { useEffect, useReducer } from 'react'; import { useEffect, useMemo, useReducer } from 'react';
import { SessionFetchErrorRightAfterLoginOrSignUp } from '../../unexpected-application-state/errors'; import { SessionFetchErrorRightAfterLoginOrSignUp } from '../../unexpected-application-state/errors';
@@ -97,12 +97,14 @@ export function useCurrentUser(): CheckedUser {
const user = session.user; const user = session.user;
return { return useMemo(() => {
id: user.id, return {
name: user.name, id: user.id,
email: user.email, name: user.name,
image: user.image, email: user.email,
hasPassword: user?.hasPassword ?? false, image: user.image,
update, hasPassword: user?.hasPassword ?? false,
}; update,
};
}, [user, update]);
} }