Storybook: knob array of objects not working as expected

Created on 15 Nov 2017  路  3Comments  路  Source: storybookjs/storybook

Version:
"@storybook/addon-knobs": "^3.2.15"

Usage:

stories
  .add('scatter', () => {
    const value = array('Data', measurements);
    return <ScatterChart width={600} height={400} min={60} data={value}></ScatterChart>
  })

measurements:

[
    {
        "high": 80,
        "time": "03:30"
    },
    {
        "high": 120,
        "time": "07:00"
    },
    {
        "high": 10,
        "time": "12:45"
    }
]

knob:
screen shot 2017-11-15 at 10 17 01

Expected:
To have the actual object representation and be able to interact with them via UI

Thx

knobs question / support

Most helpful comment

You can actually pass JSON-serializeable arrays to object knob, like this:

const value = object('Data', measurements);

1460 is for non-serializeable stuff like functions, which is not your case

All 3 comments

This should be taken care of by https://github.com/storybooks/storybook/pull/1460 but the pull request appears to have been abandoned.

You can actually pass JSON-serializeable arrays to object knob, like this:

const value = object('Data', measurements);

1460 is for non-serializeable stuff like functions, which is not your case

@Hypnosphi Thx. It works now.

Was this page helpful?
0 / 5 - 0 ratings