Fix firefox recoil snapshot bug (#2321)
fix firefox recoil snapshot bug
This commit is contained in:
@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user