Fix firefox recoil snapshot bug (#2321)

fix firefox recoil snapshot bug
This commit is contained in:
bosiraphael
2023-11-02 17:06:26 +01:00
committed by GitHub
parent 9725582a82
commit f19ed5e2e4

View File

@ -1,5 +1,4 @@
import { useEffect } from 'react'; import { useRecoilTransactionObserver_UNSTABLE, useRecoilValue } from 'recoil';
import { useRecoilSnapshot, useRecoilValue } from 'recoil';
import { isDebugModeState } from '@/client-config/states/isDebugModeState'; import { isDebugModeState } from '@/client-config/states/isDebugModeState';
import { logDebug } from '~/utils/logDebug'; import { logDebug } from '~/utils/logDebug';
@ -16,15 +15,12 @@ const formatTitle = (stateName: string) => {
}; };
export const RecoilDebugObserverEffect = () => { export const RecoilDebugObserverEffect = () => {
const snapshot = useRecoilSnapshot();
const isDebugMode = useRecoilValue(isDebugModeState); const isDebugMode = useRecoilValue(isDebugModeState);
useEffect(() => { useRecoilTransactionObserver_UNSTABLE(({ snapshot }) => {
if (!isDebugMode) { if (!isDebugMode) {
return; return;
} }
for (const node of Array.from( for (const node of Array.from(
snapshot.getNodes_UNSTABLE({ isModified: true }), snapshot.getNodes_UNSTABLE({ isModified: true }),
)) { )) {
@ -40,7 +36,6 @@ export const RecoilDebugObserverEffect = () => {
console.groupEnd(); console.groupEnd();
} }
}, [isDebugMode, snapshot]); });
return null; return null;
}; };