Skip to content

Commit

Permalink
Prevent addon state from absolutely bombing render performance
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Dec 16, 2024
1 parent c75bef5 commit b2ad07e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions code/core/src/manager-api/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
STORY_CHANGED,
} from '@storybook/core/core-events';

import { mergeWith } from 'es-toolkit';
import { isEqual } from 'es-toolkit';

import { createContext } from './context';
import getInitialState from './initial-state';
Expand Down Expand Up @@ -218,14 +218,17 @@ class ManagerProvider extends Component<ManagerProviderProps, State> {
return null!;
}

shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean {
const prevState = this.state;
shouldComponentUpdate(
nextProps: ManagerProviderProps,
{ addons: _, ...nextState }: State
): boolean {
const prevProps = this.props;
const { addons: __, ...prevState } = this.state;

if (prevState !== nextState) {
if (prevProps.path !== nextProps.path) {
return true;
}
if (prevProps.path !== nextProps.path) {
if (!isEqual(prevState, nextState)) {
return true;
}
return false;
Expand Down

0 comments on commit b2ad07e

Please sign in to comment.