fix: unexpected react warning (#4316)
This commit is contained in:
@@ -7,7 +7,12 @@ import { refreshRootMetadataAtom } from '@affine/workspace/atom';
|
|||||||
import { useAtom, useSetAtom } from 'jotai';
|
import { useAtom, useSetAtom } from 'jotai';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
||||||
import { SessionProvider, useSession } from 'next-auth/react';
|
import { SessionProvider, useSession } from 'next-auth/react';
|
||||||
import { type PropsWithChildren, startTransition, useRef } from 'react';
|
import {
|
||||||
|
type PropsWithChildren,
|
||||||
|
startTransition,
|
||||||
|
useEffect,
|
||||||
|
useRef,
|
||||||
|
} from 'react';
|
||||||
|
|
||||||
import { sessionAtom } from '../atoms/cloud-user';
|
import { sessionAtom } from '../atoms/cloud-user';
|
||||||
import { useOnceSignedInEvents } from '../atoms/event';
|
import { useOnceSignedInEvents } from '../atoms/event';
|
||||||
@@ -20,7 +25,7 @@ const SessionDefence = (props: PropsWithChildren) => {
|
|||||||
const refreshMetadata = useSetAtom(refreshRootMetadataAtom);
|
const refreshMetadata = useSetAtom(refreshRootMetadataAtom);
|
||||||
const onceSignedInEvents = useOnceSignedInEvents();
|
const onceSignedInEvents = useOnceSignedInEvents();
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
|
useEffect(() => {
|
||||||
if (sessionInAtom !== session && session.status === 'authenticated') {
|
if (sessionInAtom !== session && session.status === 'authenticated') {
|
||||||
setSession(session);
|
setSession(session);
|
||||||
}
|
}
|
||||||
@@ -48,6 +53,16 @@ const SessionDefence = (props: PropsWithChildren) => {
|
|||||||
}
|
}
|
||||||
prevSession.current = session;
|
prevSession.current = session;
|
||||||
}
|
}
|
||||||
|
}, [
|
||||||
|
session,
|
||||||
|
sessionInAtom,
|
||||||
|
prevSession,
|
||||||
|
setSession,
|
||||||
|
onceSignedInEvents,
|
||||||
|
pushNotification,
|
||||||
|
refreshMetadata,
|
||||||
|
t,
|
||||||
|
]);
|
||||||
return props.children;
|
return props.children;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user