Refactor: Memoize hook callbacks, update dependencies, and fix lint errors (#268)

Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
Allen Hutchison
2025-05-06 14:48:49 -07:00
committed by GitHub
parent e26c436d5c
commit adeda6a5b3
4 changed files with 54 additions and 41 deletions

View File

@@ -35,14 +35,14 @@ export const useThemeCommand = (
setIsThemeDialogOpen(true);
}, []);
function applyTheme(themeName: string | undefined) {
const applyTheme = useCallback((themeName: string | undefined) => {
try {
themeManager.setActiveTheme(themeName);
setForceRender((v) => v + 1); // Trigger potential re-render
} catch (error) {
console.error(`Error setting theme: ${error}`);
}
}
}, []);
const handleThemeHighlight = useCallback(
(themeName: string | undefined) => {
@@ -61,7 +61,7 @@ export const useThemeCommand = (
setIsThemeDialogOpen(false); // Close the dialog
}
},
[applyTheme], // Added applyTheme to dependencies
[applyTheme, loadedSettings],
);
return {