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.

Storybook 4 migration addon-knobs is not working

See original GitHub issue

Hi Team

After migration to Storybook 4, I am facing an issue with addon-knobs, the panel appears but with “No Knobs” string, where almost every story contains knobs to change the properties of the component.

Before the migration, these were working.

Small Info about the current project structure setup:

  1. addon.js contains the following:
import '@storybook/addon-knobs/register'
  1. config.js contains the following code:
import { withKnobs } from '@storybook/addon-knobs'

const req = require.context('../stories', false, /\-story\.tsx$/)

function loadStories() {
  req.keys().forEach(filename => req(filename))
}

addDecorator(withNotes)
addDecorator(withKnobs)
  1. small-story.tsx looking like below:
import * as React from 'react'
import { MemoryRouter } from 'react-router'
import { object } from '@storybook/addon-knobs'
import { getStory, StoryInfo, addChapter } from './common'
import { Component } from './imports'

const storyInfo: StoryInfo = { label: 'Component ', readMeKey: 'ComponentReadme' }
const defaultValue = [
  { _id: 'newId_1', label: 'Test 101' },
  { _id: 'newId_2', label: Test 102' },
]

const ComponentStory = getStory(storyInfo).addDecorator((story: any) => (
  <MemoryRouter initialEntries={['/']}>{story()}</MemoryRouter>
))

addChapter(
  ComponentStory ,
  {
    name: 'introduction',
    information: `Displaying the naviagtion path to the current node`,
    note: `To Display bread crumbs in order to show path`,
  },
  <Component prop={object('prop', defaultValue)} />,
)

If you need more information from my side, please let me know.

Any pointers or hints will be useful.

Thanks and regards Amit

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mbellary-chwycommented, Dec 3, 2018

@amittkSharma and @KudMath.

package.json dependencies

"@storybook/addon-a11y": "4.0.9",
"@storybook/addon-knobs": "4.0.9",
"@storybook/addon-links": "4.0.9",
"@storybook/addon-options": "4.0.8",
"@storybook/addon-storyshots": "4.0.9",
"@storybook/addon-storysource": "4.0.9",
"@storybook/addon-viewport": "4.0.9",
"@storybook/addons": "4.0.9"

Note: I did not add withKnobs decorator globally, I added it to respective components which have KNOBS like below:

storiesOf(‘Vue.Carousel’, module) .addDecorator( withKnobs({ escapeHTML: false }) ) .addParameters({ options: { selectedAddonPanel: ‘storybooks/storybook-addon-knobs’ } }) .add(‘Playground’, () => ({ … }));

withKnobsOptions is deprecated in Storybooks 4.0

0reactions
tjenkinsoncommented, Oct 2, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Storybook Addon Knobs (deprecated)
Storybook Addon Knobs allow you to edit props dynamically using the Storybook UI. You can also use Knobs as a dynamic variable inside...
Read more >
Storybook problem while migrating argument of type object ...
Can I create a Knob in React Storybook to modify an array with 4 values where each value has a select dropdown? 3...
Read more >
storybook-addon-playwright - npm
An addon to visually test the stories in the multiple browsers within storybook environment. Addon will not work in storybook static build, ...
Read more >
@types/storybook__addon-knobs | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
MIGRATION.md - Storybook - Fossies
React 16.3+; Generic addons; Knobs select ordering; Knobs URL parameters ... Does not work with storiesOf(); Does not work if you use dynamic...
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