Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Button knobs get extra callbacks on hot reload #8298

Closed
dcecile opened this issue Oct 4, 2019 · 0 comments · Fixed by #8408
Closed

Button knobs get extra callbacks on hot reload #8298

dcecile opened this issue Oct 4, 2019 · 0 comments · Fixed by #8408
Assignees

Comments

@dcecile
Copy link

dcecile commented Oct 4, 2019

Describe the bug
Button knobs get an extra callback added for each hot reload of Storybook. Many source code changes results in button knob effects getting applied many times.

To Reproduce
Steps to reproduce the behavior:

  1. Set up my minimal stories:
git clone https://github.com/dcecile/storybook-react-ts-knobs.git
cd storybook-react-ts-knobs
yarn install
yarn view
  1. Click a button knob, see increment/decrement by 1
  2. Keeping Storybook running, change a source file, see it hot reload
  3. Click a button knob, see increment/decrement by 2
  4. Repeat for more extra callbacks added with each hot reload

Expected behavior
Always increment/decrement by 1, regardless of number of hot reloading.

Screenshots
N/A

Code snippets

storiesOf("div", module)
    .add("button counter knob", () => {
        const [counter, setCounter] = useState(0)
        button("increment", () => setCounter(counter + 1))
        button("decrement", () => setCounter(counter - 1))
        return <div>{counter}</div>
    })

System:

  System:
    OS: macOS Mojave 10.14.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7500 CPU @ 3.40GHz
  Binaries:
    Node: 12.9.0 - /var/folders/fc/ph40lnkd7198grpr18pjmj5r0000gn/T/yarn--1570226478667-0.2814044355556453/node
    Yarn: 1.17.3 - /var/folders/fc/ph40lnkd7198grpr18pjmj5r0000gn/T/yarn--1570226478667-0.2814044355556453/yarn
    npm: 6.10.3 - /usr/local/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 68.0.1
    Safari: 13.0.1
  npmPackages:
    @storybook/addon-actions: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/addon-info: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/addon-knobs: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/addon-notes: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/addons: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/cli: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/react: ^5.3.0-alpha.9 => 5.3.0-alpha.9
    @storybook/theming: ^5.3.0-alpha.9 => 5.3.0-alpha.9

Additional context
This bug was exposed once button knobs got fixed for #8165.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants