Skip to content

Commit

Permalink
refactor: memoize the usePanelPreferences hook
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Aug 29, 2024
1 parent 26d86f3 commit 08739b2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/component/hooks/usePanelPreferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,11 @@ export function usePanelPreferencesByNuclei<T extends Panel>(
): UsePanelPreferencesByNucleiResult<T> {
const { current } = usePreferences();

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { nuclei: omitNuclei = null, ...restPreferences } = getPanelPreferences(
current,
panelKey,
);

return useMemo(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { nuclei: omitNuclei = null, ...restPreferences } =
getPanelPreferences(current, panelKey);

return {
nuclei: Object.fromEntries(
nuclei.map((nucleusLabel) => [
Expand All @@ -183,5 +181,5 @@ export function usePanelPreferencesByNuclei<T extends Panel>(
),
...restPreferences,
};
}, [current, nuclei, panelKey, restPreferences]);
}, [current, nuclei, panelKey]);
}

0 comments on commit 08739b2

Please sign in to comment.