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!
I'm also getting this error :(
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.
Hi @mcookdev,
but isn't using manager.js the new of customizing the theme in [email protected]? 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?
This is also explained in the new theming documation: https://storybook.js.org/docs/configurations/theming/
Most helpful comment
I think I figured it out. I was setting a theme using
And it should have been:
Also, If no custom theme is set, the error does not appear.