Skip to content

Commit f41187d

Browse files
committed
Refactor useDomainTracking to defer domain check in useEffect
- Updated the useEffect hook to defer the call to checkDomain using setTimeout, preventing synchronous setState during the effect execution. - This change improves performance and ensures smoother state updates when allowlist or denylist changes occur.
1 parent 6f2d1a5 commit f41187d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/pages/devtools/hooks/useDomainTracking.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ export function useDomainTracking({
215215

216216
// Check domain on mount and when allowlist/denylist changes
217217
useEffect(() => {
218-
checkDomain();
218+
// Defer the call to avoid synchronous setState in effect
219+
const timeoutId = setTimeout(() => {
220+
checkDomain();
221+
}, 0);
222+
return () => clearTimeout(timeoutId);
219223
}, [checkDomain]);
220224

221225
// Listen for domain change messages from background script

0 commit comments

Comments
 (0)