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

View File

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