You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm facing an issue where I am unable to grab the theme object inside a Story unless some hack is used.
The thing is that, the React component itself have no problem getting the theme, but the issue is with the story itself.
There is a "workaround" (is in double quote because it caused other error!) if you render the story as a component (instead of story function, then it would be able to get the properties and get the theme. BUT, rendering the story as a component would ended up causing the following error in some other story!!!!
Storybook preview hooks can only be called inside decorators and story functions
In addition, there is an "interesting" weird hack that could workaround the problem... is to add a decorator right before the story itself. And no, you cannot add the hack with addDecorator in preview.js, that won't work, the only way is to add it inside the storybook file...
We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:
Related: mui/material-ui#24282 (comment)
I'm facing an issue where I am unable to grab the theme object inside a Story unless some hack is used.
The thing is that, the React component itself have no problem getting the theme, but the issue is with the story itself.
There is a "workaround" (is in double quote because it caused other error!) if you render the story as a component (instead of story function, then it would be able to get the properties and get the theme. BUT, rendering the story as a component would ended up causing the following error in some other story!!!!
I am using pretty much everything latest:
Decorator in the
preview.js
Where
MyThemeProvider
just wraps both Mui's and StyledComponent's provider like soThen in any story, I just try to grab the theme object and it simply returned
undefined
In addition, there is an "interesting" weird hack that could workaround the problem... is to add a decorator right before the story itself. And no, you cannot add the hack with
addDecorator
inpreview.js
, that won't work, the only way is to add it inside the storybook file...With that, the story would get the
theme
object... go figure?The text was updated successfully, but these errors were encountered: