Skip to content

Commit

Permalink
Merge pull request #30192 from storybookjs/valentin/add-memoization-f…
Browse files Browse the repository at this point in the history
…or-addon-panel-calculation

Manager: Optimize getPanels function with memoization
  • Loading branch information
valentinpalkovic authored Jan 7, 2025
2 parents 4162860 + 2adf23d commit 89d1d0e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions code/core/src/manager/container/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 89d1d0e

Please sign in to comment.