Is there a way to display the key of the object of the array as props?
See original GitHub issueIs 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:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@Inhye-Cheong you can do it manually in story argTypes
Then it looks like
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!