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.

Is there a way to display the key of the object of the array as props?

See original GitHub issue

Is your feature request related to a problem? Please describe. Is there a way to display the key of the object of the array as props in storybook? (not just inline props definition)

Describe alternatives you’ve considered I want to show the details of the Content type in storybook props (like Content[{title: string, description: string}]), but it only displays Content[]. Is there any way?

type Content = {
  title: string;
  description: string;
};
type Props = {
  lists: Content[];
};
export const SOME_COMPONENT: FC<Props> = ({lists}) => {
  : 
  : 
};

Additional context

  • storybook v6.0.18
  • addons
addons: [
    '@storybook/addon-docs',
    '@storybook/addon-knobs',
    '@storybook/addon-viewport',
  ]
  • loaders url-loaders, babel-loader, react-docgen-typescript-loader

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ajkl2533commented, Aug 31, 2020

@Inhye-Cheong you can do it manually in story argTypes

story.argTypes = {
  lists: {
    table: {
      type: {
        summary: 'Content[]',  // <- this is probably not needed
        detail: `
[
  {
    title: string;
    description: string;
  }
]
        `,
      },
    },
  },
};

Then it looks like Screenshot 2020-08-31 at 11 16 34

0reactions
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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Accessing Data through Props with Known Key Names in ...
Access Props Data with the Known Key Name Using Object.entries() ... The Object.entries() is another way to extract the number of key-value pairs ......
Read more >
Object.keys() - JavaScript - MDN Web Docs
The Object.keys() method returns an array of a given object's own enumerable string-keyed property names. Try it.
Read more >
Lists and Keys - React
In React, transforming arrays into lists of elements is nearly identical. ... The best way to pick a key is to use a...
Read more >
Mapping object keys in react and returning child properties
It seems like result[item] should be an array correct? So you would need to map over that array as well. result[item][0].name should return...
Read more >
Pass an Array as Props - React - Free Code Camp - YouTube
In this React tutorial we pass an array as props. This video constitutes one part of many where I cover the FreeCodeCamp ...
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