Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(core): rerender (#4988)

EYHN899e46b1fa06
diff --git a/packages/frontend/core/src/hooks/affine/use-current-user.ts b/packages/frontend/core/src/hooks/affine/use-current-user.ts
index a20bf6650e..4388cc0178 100644
--- a/packages/frontend/core/src/hooks/affine/use-current-user.ts
+++ b/packages/frontend/core/src/hooks/affine/use-current-user.ts
@@ -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]);
}