question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addon-knobs Select | Option values as Arrays

See original GitHub issue

Describe the bug As of v5.1.9 I could use arrays or any custom type as an option value with the select knob. This functionality is now not allowed as of v5.2.0-beta.*.

To Reproduce Steps to reproduce the behavior:

  1. Create the following select knob
const mySweetSelect = select(
  'mySelect',
  {
    ones: [1],
    twos: [2, 2],
    threes: [3, 3, 3],
  },
  [1],
);
  1. Notice with v5.2.0-beta.19 there is a type error for the option values as the select option value can only be one of… https://github.com/storybookjs/storybook/blob/ec0fcd4fc41139d9b3d4241dd160d3c9936d7200/addons/knobs/src/components/types/Select.tsx#L7

It looks like since v5.1.9 you upgrade to typescript ( yay! 🎉) but this value restriction causes a breaking change. I wasn’t sure to put this as a feature or bug but since it broke my current usage I decided to label it as a bug. Also considering it is allowable to have arrays as values per the latest docs.

Expected behavior Allow a generic type as an option value…

type MySpecialType = number[];
const mySweetSelect = select<MySpecialType>(
  'mySelect',
  {
    ones: [1],
    twos: [2, 2],
    threes: [3, 3, 3],
  },
  [1],
);

System:

System: OS: macOS 10.14.5 CPU: (16) x64 Intel® Core™ i9-9980HK CPU @ 2.40GHz Binaries: Node: 10.15.2 - ~/.nvm/versions/node/v10.15.2/bin/node Yarn: 1.16.0 - /usr/local/bin/yarn npm: 6.9.0 Browsers: Chrome: 75.0.3770.142 Safari: 12.1.1

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
emilio-martinezcommented, Jul 31, 2019

@shilman sure thing! I’m on it 😃

1reaction
shilmancommented, Sep 8, 2019

Olé!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-rc.9 containing PR #8027 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there’s still more to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Knobs Addon | Storybook: Frontend workshop for UI ...
It allows you to get a value from a select box from the user. import { select } from '@storybook/addon-knobs'; const label =...
Read more >
Can I create a Knob in React Storybook to modify an array ...
Can I create a Knob in React Storybook to modify an array with 4 values where each value has a select dropdown? Ask...
Read more >
@storybook/addon-knobs - npm
Start using @storybook/addon-knobs in your project by running `npm i ... Allows you to get a value from a select box from the...
Read more >
Simple Example of Storybook with React, With Knobs, With ...
All knobs have the same kind of syntax with little variation so for select syntax is. select( name Of select, Options, Default Value, ......
Read more >
How to use the @storybook/addon-knobs.array function ... - Snyk
To help you get started, we've selected a few @storybook/addon-knobs examples, ... NOTE: the default value must not change - e.g., do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found