Skip to content

Commit f6b9728

Browse files
authored
chore: Apply act warning fix to all hooks that uses useMutationObserver (#104)
1 parent 2b188cf commit f6b9728

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/internal/visual-mode/index.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ export function useCurrentMode(elementRef: React.RefObject<HTMLElement>) {
3636
node,
3737
node => node.classList.contains('awsui-polaris-dark-mode') || node.classList.contains('awsui-dark-mode')
3838
);
39-
setValue(darkModeParent ? 'dark' : 'light');
39+
const newValue = darkModeParent ? 'dark' : 'light';
40+
41+
// refer to the comment below in `useReducedMotion`
42+
if (newValue !== value) {
43+
setValue(newValue);
44+
}
4045
});
4146
return value;
4247
}
@@ -48,7 +53,12 @@ export function useDensityMode(elementRef: React.RefObject<HTMLElement>) {
4853
node,
4954
node => node.classList.contains('awsui-polaris-compact-mode') || node.classList.contains('awsui-compact-mode')
5055
);
51-
setValue(compactModeParent ? 'compact' : 'comfortable');
56+
const newValue = compactModeParent ? 'compact' : 'comfortable';
57+
58+
// refer to the comment below in `useReducedMotion`
59+
if (newValue !== value) {
60+
setValue(newValue);
61+
}
5262
});
5363
return value;
5464
}

0 commit comments

Comments
 (0)