From 7a288c2b9721c66fc4c384032a51ccfa3a3d6f9d Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Thu, 31 Jul 2025 14:25:33 +0200 Subject: [PATCH] Ignore preparing/loading phases --- code/core/src/component-testing/components/Panel.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/core/src/component-testing/components/Panel.tsx b/code/core/src/component-testing/components/Panel.tsx index c2130d8485de..16df7a552a67 100644 --- a/code/core/src/component-testing/components/Panel.tsx +++ b/code/core/src/component-testing/components/Panel.tsx @@ -253,12 +253,18 @@ export const Panel = memo<{ refId?: string; storyId: string; storyUrl: string }> ); }, [STORY_RENDER_PHASE_CHANGED]: (event) => { + if (event.newPhase === 'preparing' || event.newPhase === 'loading') { + // A render cycle may not actually make it to the rendering phase. + // We don't want to update any state until it does. + return; + } + lastRenderId.current = Math.max(lastRenderId.current, event.renderId || 0); if (lastRenderId.current !== event.renderId) { return; } - if (event.newPhase === 'preparing') { + if (event.newPhase === 'rendering') { log.current = [getInternalRenderLogItem(CallStates.ACTIVE)]; calls.current.set(INTERNAL_RENDER_CALL_ID, getInternalRenderCall(storyId)); set({