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

Error when used with Storybook 5.3+ #220

Closed
mcookdev opened this issue Jan 17, 2020 · 3 comments
Closed

Error when used with Storybook 5.3+ #220

mcookdev opened this issue Jan 17, 2020 · 3 comments

Comments

@mcookdev
Copy link

When I use storybook-readme with the latest Storybook (5.3.x) I receive the following error.

Cannot read property 'theme' of undefined

TypeError: Cannot read property 'theme' of undefined
    at getParameters (http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:113604:63)
    at wrapper (http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:113334:49)
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:18748:14
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:18762:26
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:18272:21
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:19791:14
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:19792:16
    at wrapper (http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:17745:12)
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:18748:14
    at http://localhost:6006/vendors~main.bff5a406979c62ca8ff1.bundle.js:18762:26

This only appears when I use this addon. On the bright side, I figured out a temporary workaround by using:

addParameters({
  options: { theme: {} }
});

We find the plugin to be very useful for our projects and we appreciate your help!

@brandon-pereira
Copy link

I'm also getting this error :(

@mcookdev
Copy link
Author

mcookdev commented Jan 21, 2020

I think I figured it out. I was setting a theme using

const theme = create({
  base: "light",
  brandTitle: "My Brand",
  brandUrl: "https://mybrand.com",
  brandImage: "/logo.png"
});

addons.setConfig({
  theme
});

And it should have been:

addParameters({
  options: {
    theme: create({
      base: "light",
      brandTitle: "My Theme",
      brandUrl: "https://mybrand.com",
      brandImage: "/mylogo.png"
    })
  }});

Also, If no custom theme is set, the error does not appear.

@natterstefan
Copy link

natterstefan commented Jan 22, 2020

Hi @mcookdev,

but isn't using manager.js the new of customizing the theme in Storybook@5.3? At least this is what is illustrated in the migration guide 5.2.x -> 5.3.x:

If you are setting storybook options in config.js, especially theme, you should migrate it to manager.js (...) This makes storybook load and use the theme in the manager directly. This allows for richer theming in the future, and has a much better performance!

This would mean this is an issue that should be fixed, right?

https://github.com/tuchk4/storybook-readme/blob/master/packages/storybook-readme/src/services/getParameters.js#L16-L18

This is also explained in the new theming documation: https://storybook.js.org/docs/configurations/theming/

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

No branches or pull requests

3 participants