Skip to content

Commit

Permalink
Manager: Optimize getPanels function with memoization
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jan 6, 2025
1 parent de65bec commit aa120bb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions code/core/src/manager/container/Panel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import React from 'react';
import React, { useCallback } from 'react';

import { Addon_TypesEnum } from '@storybook/core/types';

Expand All @@ -16,7 +16,7 @@ const createPanelActions = memoize(1)((api) => ({
togglePosition: () => api.togglePanelPosition(),
}));

const getPanels = (api: API) => {
const getPanels = memoize(1)((api: API) => {
const allPanels = api.getElements(Addon_TypesEnum.PANEL);
const story = api.getCurrentStoryData();

Expand All @@ -42,7 +42,7 @@ const getPanels = (api: API) => {
});

return filteredPanels;
};
});

const mapper = ({ state, api }: Combo) => ({
panels: getPanels(api),
Expand Down

0 comments on commit aa120bb

Please sign in to comment.