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

Knobs reset local state in storybook 6 #16

Open
dontsave opened this issue Sep 28, 2020 · 2 comments
Open

Knobs reset local state in storybook 6 #16

dontsave opened this issue Sep 28, 2020 · 2 comments

Comments

@dontsave
Copy link

Describe the bug
In Storybook 6, changing a knob's value causes local state to reset to default. Repro:

To Reproduce

import React, { useState } from 'react';
import { number, withKnobs } from '@storybook/addon-knobs';

export const Test = () => {
  number(`num`, 0);
  const [state, setState] = useState(0);
  return <div onClick={() => setState((s) => s + 1)}>{state}</div>;
};

export default { title: `testing`, component: Test, decorators: [withKnobs] };

clicking the div above will increment the output value, but then if you change the num knob, the value resets to 0. This does not happen in storybook 5.

@shilman
Copy link
Member

shilman commented Sep 28, 2020

FYI, we’ve released addon-controls in Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replace addon-knobs long term.

Please upgrade and try them out today!

@stale
Copy link

stale bot commented Dec 26, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@shilman shilman transferred this issue from storybookjs/storybook May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants