storybook: [Bug]: TypeError: Cannot read properties of undefined (reading 'count') with onClick action

Describe the bug

image image

To Reproduce

just setup a react app with webpack or vite, then install storybook and create a story for a single button component

System

Environment Info:

  System:
    OS: macOS 13.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 18.13.0 - ~/.nodenv/versions/18.13.0/bin/node
    Yarn: 1.22.19 - ~/.nodenv/versions/18.13.0/bin/yarn
    npm: 9.6.7 - ~/.nodenv/versions/18.13.0/bin/npm
  Browsers:
    Chrome: 115.0.5790.170
    Safari: 16.6
  npmPackages:
    @storybook/addon-essentials: ^7.2.1 => 7.2.1
    @storybook/addon-interactions: ^7.2.1 => 7.2.1
    @storybook/addon-links: ^7.2.1 => 7.2.1
    @storybook/addon-onboarding: ^1.0.8 => 1.0.8
    @storybook/blocks: ^7.2.1 => 7.2.1
    @storybook/react: ^7.2.1 => 7.2.1
    @storybook/react-webpack5: ^7.2.1 => 7.2.1
    @storybook/testing-library: ^0.2.0 => 0.2.0

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 16
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Just updated to Storybook 7.4.0 and I’m still seeing this error. After a manual reload of Storybook, any action that’s tracked by the Actions addon starts throwing this error again, until I switch to a different story. Exact same problem as before.

I have the same error, here are my remarks:

  • When I reload page at Story1 and click button on it, the error occur and Actions are not collected
  • When I change from Story1 to Story2 and click button on it, the error is gone and Actions are collected
  • When I change back from Story2 to Story1 and click button on it, the error is not appearing anymore and Actions are collected

So - from my understanding - it means, the error happens when clicking button right after on page load and not when we re-render 🤔

@ndelangen here’s what I learned when trying to reproduce:

  • Still occurs in 7.5.0-alpha.2
  • Only happens when the interactions tab is focused, and the page is reloaded

Here’s a repro: https://stackblitz.com/edit/github-iz1qiv?file=src%2Fstories%2FButton.stories.ts

Because you can’t reload the page in stackblitz, you’ll need to download the project and run locally.

Same, downgrading @storybook/addon-essentials to 7.1.1 fixes it.

We’re facing the same issue : Cannot read properties of undefined (reading 'count') when we click on a checkbox before clicking in any other field on the page.

I have the same error, here are my remarks:

  • When I reload page at Story1, the error occur and Actions are not collected
  • When I change from Story1 to Story2, the error is gone and Actions are collected
  • When I change back from Story2 to Story1, the error is not appearing anymore and Actions are collected

So - from my understanding - it means, the error happens on page load and not when we re-render 🤔

for me it happens whenever I trigger the assigned action, e.g. click the button.