Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knobs stopped handling object values properly #4500

Closed
Hypnosphi opened this issue Oct 19, 2018 · 2 comments
Closed

Knobs stopped handling object values properly #4500

Hypnosphi opened this issue Oct 19, 2018 · 2 comments

Comments

@Hypnosphi
Copy link
Member

Hypnosphi commented Oct 19, 2018

import React from 'react'
import {storiesOf} from '@storybook/react'
import {withKnobs, select} from '@storybook/addon-knobs'

const options = {
  first: {foo: 'foo},
  second: {bar: 'bar'},
}

storiesOf('MyComponent', module)
  .addDecorator(withKnobs)
  .add('MyComponent', () => (
    <MyComponent
      object={select('Option', options, options.second)}
    />
  )

Expected: "second" selected in knob
Actual: "first" selected in knob
After trying to select other value in knob, "[object Object]" gets passed to MyComponent

The workaround is to use object keys instead:

<MyComponent
  object={options[select('Option', Object.keys(options), 'second')]}
/>
@lapa182
Copy link

lapa182 commented Nov 9, 2018

Is there a feedback with this issue? Having the same problem.

@Hypnosphi
Copy link
Member Author

I believe it was fixed with #4522. Which storybook version do you use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants