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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ import { type User } from '@affine/component/auth-components';
import type { DefaultSession, Session } from 'next-auth';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
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';
@ -97,12 +97,14 @@ export function useCurrentUser(): CheckedUser {
const user = session.user;
return {
id: user.id,
name: user.name,
email: user.email,
image: user.image,
hasPassword: user?.hasPassword ?? false,
update,
};
return useMemo(() => {
return {
id: user.id,
name: user.name,
email: user.email,
image: user.image,
hasPassword: user?.hasPassword ?? false,
update,
};
}, [user, update]);
}