fix(core): rerender (#4988)
This commit is contained in:
@@ -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]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user