Skip to content

Commit

Permalink
Merge pull request #30081 from storybookjs/fix-infinite-rerender
Browse files Browse the repository at this point in the history
Core: Prevent infinite rerendering caused by comparison by reference
  • Loading branch information
ghengeveld authored Dec 19, 2024
2 parents df37d08 + 8e2e08f commit 3d2eaaf
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 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 @@ -219,16 +219,9 @@ class ManagerProvider extends Component<ManagerProviderProps, State> {
}

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

if (prevState !== nextState) {
return true;
}
if (prevProps.path !== nextProps.path) {
return true;
}
return false;
const prevState = this.state;
return prevProps.path !== nextProps.path || !isEqual(prevState, nextState);
}

initModules = () => {
Expand Down

0 comments on commit 3d2eaaf

Please sign in to comment.