Controls - type array of objects displayed wrongly
See original GitHub issueDescribe the bug
If use argTypes control type array
for array of object, in the UI it will display [object Object] instead of proper value, because it tries to “serialize array into a comma-separated string inside a textbox” .
To Reproduce Steps to reproduce the behavior:
- Set the
argTypes
of the component doc
argTypes: {
breadcrumbs: {
control: "array",
table: {
category: "Props",
},
},
},
- Set the args of the specific story to array of object
Template.args = {
breadcrumbs: [
{ text: "Home", link: "#" },
{ text: "Category", link: "#" },
{ text: "Pants", link: "#" },
],
};
- Go to Storybook page of that component, it prints
[object Object],[object Object],[object Object]
Expected behavior
It should display { text: "Home", link: "#" }, { text: "Category", link: "#" }, { text: "Pants", link: "#" }
Screenshots
System Environment Info:
System: OS: macOS 10.15.7 CPU: (12) x64 Intel® Core™ i7-8850H CPU @ 2.60GHz Binaries: Node: 14.13.0 - /usr/local/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Browsers: Chrome: 87.0.4280.88 Firefox: 76.0.1 Safari: 14.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:6 (4 by maintainers)
Top Results From Across the Web
mapping an object array incorrectly in React? - Stack Overflow
My goal is to display all 4 buttons(terms), and only show the definition for that term. As it is now it keeps showing...
Read more >Understanding the "Objects are not valid as a react child" Error ...
Lists, tables, cards, buttons, and other types of components are very often applied through the usage of the .map() array method.
Read more >Get a Unique List of Objects in an Array of Object in JavaScript
To the tutorial! : https://yagisanatode.com/2021/07/03/get-a-unique-list-of- objects -in-an- array-of-object -in-javascript/00:00 Intro00:38 ...
Read more >JavaScript typed arrays - MDN Web Docs
JavaScript typed arrays are array-like objects that provide a mechanism for reading and writing raw binary data in memory buffers.
Read more >Create a custom action to generate an array of objects from a ...
Our feedback system is currently not working as expected. As a workaround, you can email docfeedback@servicenow.com. Thank you for your patience while we ......
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 FreeTop 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
Top GitHub Comments
I really like the
console.table
suggestion. Like Chrome, it should automatically infer the right columns (based on all the rows rather than the first, so partial objects just have empty cells). I’ve opened a feature request for that: #14266As of Storybook 6.2, arrays are inferred to use the
object
control type, which renders the JSON editor, regardless of whether the values are primitive or not.If all the objects in the array have the same keys, it could make sense to have a “table” display type (like the chrome
console.table
instead of using a JSON tree. We could have the option of either trying to infer the keys by default using the first object in the array, or letting the user pass in an explicit list of properties to use in the table.