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.

Storybook 6.0 args don't maintain array order.

See original GitHub issue

Describe the bug When using both typescript types and argTypes, the order of args are not maintained.

To Reproduce Steps to reproduce the behavior:

  1. Create a component that has a prop with multiple options
  2. Add story with args
  3. See arg order is not maintained

Expected behavior Args are ordered

Screenshots Screen Shot 2020-07-18 at 3 41 17 PM

Code snippets using this as props

interface Props {
  src: string;
  alt: string;
  size: 'smallest' | 'small' | 'medium' | 'large' | 'largest';
}
export function Example(
  args: React.ComponentPropsWithoutRef<typeof UIAvatar>
): JSX.Element {
  return <UIAvatar {...args} />;
}

Example.args = {
  src: 'avatar.jpg',
  alt: 'Avatar',
  size: 'medium',
};

System: Please paste the results of npx -p @storybook/cli@next sb info here.

Environment Info:

System: OS: macOS 10.15.6 CPU: (12) x64 Intel® Core™ i7-8750H CPU @ 2.20GHz Binaries: Node: 12.8.1 - ~/n/bin/node Yarn: 1.22.4 - ~/.yarn/bin/yarn npm: 6.14.5 - ~/n/bin/npm Browsers: Firefox: 72.0.2 Safari: 13.1.2

Additional context I don’t know if this is possible, but I love you

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lifeiscontentcommented, Jul 20, 2020

@shilman I looked into it more on the TypeScript side, looks like it might be planned to fix this behavior upstream, but currently no fix.

https://github.com/Microsoft/TypeScript/issues/17944

0reactions
shilmancommented, Apr 13, 2021

We added user-configurable sorting here:

https://github.com/storybookjs/storybook/pull/13125

Read more comments on GitHub >

github_iconTop Results From Across the Web

Args - Storybook - JS.ORG
“Args” are Storybook's mechanism for defining those arguments in a single JavaScript object. Args can be used to dynamically change props, slots, styles, ......
Read more >
Changing args values / state in Storybook (without useState ...
A quick glance at how to change your stories args values within Storybook and ReactJs. To be combined with Storybook Controls.
Read more >
Storybook 6 - how to set array of objects? - Stack Overflow
Data prop is an array of objects and I am trying to pass it like this: const data = [ object('First', {color: '#fa2dac',...
Read more >
Classes and Generics - C# 6.0 Cookbook, 4th Edition [Book]
The Add method of the SortedList<K,V> class uses this interface to sort the ... The first two accept no arguments, but the last...
Read more >
SugarCube v2 Documentation - Motoslave.net
If you need them, then you'll need to keep them out of story variables. ... and text arguments are accepted, the order is...
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