Skip to content

Commit

Permalink
Revert 24451
Browse files Browse the repository at this point in the history
(cherry picked from commit 9a7a820)
  • Loading branch information
kasperpeulen committed Feb 15, 2024
1 parent 7a98580 commit 91a8921
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions code/addons/interactions/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable no-param-reassign,no-underscore-dangle */
/* eslint-disable no-param-reassign, no-underscore-dangle */
/// <reference types="node" />

import { addons } from '@storybook/preview-api';
import { global } from '@storybook/global';
import { FORCE_REMOUNT, STORY_RENDER_PHASE_CHANGED } from '@storybook/core-events';
Expand All @@ -21,6 +20,7 @@ const fn = JestMock.fn.bind(JestMock);
// Aliasing `fn` to `action` here, so we get a more descriptive label in the UI.
const { action } = instrument({ action: fn }, { retain: true });
const channel = addons.getChannel();
const seen = new Set<any>();
const spies: any[] = [];

channel.on(FORCE_REMOUNT, () => spies.forEach((mock) => mock?.mockClear?.()));
Expand All @@ -29,6 +29,8 @@ channel.on(STORY_RENDER_PHASE_CHANGED, ({ newPhase }) => {
});

const addSpies = (id: string, val: any, key?: string): any => {
if (seen.has(val)) return val;
seen.add(val);
try {
if (Object.prototype.toString.call(val) === '[object Object]') {
// We have to mutate the original object for this to survive HMR.
Expand Down

0 comments on commit 91a8921

Please sign in to comment.