Storybook: Accessing nonexistent addons channel, using storybook withKnobs and React.js

Created on 27 Feb 2019  路  4Comments  路  Source: storybookjs/storybook

Describe the bug
I keep receiving the following error when implmenting withKnobs using storybook. This is my current config. I have it creating an '..example.js' on the fly. See attached.

To Reproduce
Steps to reproduce the behavior:

  1. Copy snippet below and paste into 'config.js'

Expected behavior
Run as normal with knobs integrated

Screenshots

Code snippets
This creates '...example.js' on the fly

import React from "react";
import path from "path";
import { configure } from "@storybook/react";
import { getStorybook, storiesOf } from "@storybook/react";
import { withKnobs } from '@storybook/addon-knobs';

let getComponentName = filePath =>
  path
    .dirname(filePath)
    .split(path.sep)
    .reverse()[0];

let getPackageName = filePath =>
  path
    .dirname(filePath)
    .split(path.sep)
    .reverse()[1];

configure(() => {

  // Automatically import all examples
  const req = require.context(
    "../packages",
    true,
    /^((?!node_modules).)*\.example\.js$/
  );

req.keys().forEach(pathToExample => {
    const { name, Example } = req(pathToExample);
    const componentName = `${getPackageName(pathToExample)}.${getComponentName(
      pathToExample
    )}`;

    //This works
    //storiesOf(componentName, module).add(name, () => <Example />)

    const stories = storiesOf(componentName, module);
    stories.addDecorator(withKnobs);

    stories.add(name, () => (
      <Example />
    ));

  });
}, module);

export { getStorybook };

System:

  • OS: [MacOS]
  • Device: [Macbook Pro 2018]
  • Browser: [chrome]
  • Framework: [react]
  • Addons: [withKnobs]
  • Version: " @storybook/addon-actions": "^4.1.13", "@storybook/addon-knobs": "^4.1.13", "@storybook/addon-links": "^4.1.13", "@storybook/addon-notes": "^4.1.13", "@storybook/addons": "^4.1.13", "@storybook/react": "^3.4.11",

Additional context
Add any other context about the problem here.

knobs question / support

All 4 comments

Does it work if you addDecorator(withKnobs) globally outside of the configure function?

No, still running into the same issue. It displays no panels found even for my action logger when I remove everything but keep it registered in my 'addons.js' file

screen shot 2019-02-28 at 9 39 10 am
screen shot 2019-02-28 at 9 39 31 am

@jephjohnson I see the problem. You should be using the same version of everything. So either use @storybook/[email protected] OR use @storybook/addon*@3.4.11 (I suggest using the most recent version).

Closing for now. Please re-open if that wasn't the problem.

Solid!!! Thanks @shilman

Was this page helpful?
0 / 5 - 0 ratings