Skip to content

Commit e24a14f

Browse files
authored
Merge pull request #32163 from storybookjs/no-state-change-before-rendering
Core: Don't update interactions panel state until we reach the rendering phase
2 parents d3746ae + 7a288c2 commit e24a14f

File tree

1 file changed

+7
-1
lines changed
  • code/core/src/component-testing/components

1 file changed

+7
-1
lines changed

code/core/src/component-testing/components/Panel.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,12 +253,18 @@ export const Panel = memo<{ refId?: string; storyId: string; storyUrl: string }>
253253
);
254254
},
255255
[STORY_RENDER_PHASE_CHANGED]: (event) => {
256+
if (event.newPhase === 'preparing' || event.newPhase === 'loading') {
257+
// A render cycle may not actually make it to the rendering phase.
258+
// We don't want to update any state until it does.
259+
return;
260+
}
261+
256262
lastRenderId.current = Math.max(lastRenderId.current, event.renderId || 0);
257263
if (lastRenderId.current !== event.renderId) {
258264
return;
259265
}
260266

261-
if (event.newPhase === 'preparing') {
267+
if (event.newPhase === 'rendering') {
262268
log.current = [getInternalRenderLogItem(CallStates.ACTIVE)];
263269
calls.current.set(INTERNAL_RENDER_CALL_ID, getInternalRenderCall(storyId));
264270
set({

0 commit comments

Comments
 (0)