Skip to content

Knobs reset local state in storybook 6 #16

Open

Description

@dontsave

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.

Activity

  1. shilman commented on Sep 28, 2020

    @shilman
    Contributor

    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!

  2. stale commented on Dec 26, 2020

    @stale

    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!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions