With Storybook 7, the forceReRender() has been removed. And with its replacement channel.emit(FORCE_RE_RENDER);, the class in the componentWrapperDecorator is not updated anymore.
I tried several things, but nothing worked in all cases. Finally, I found this example of a global componentWrapperDecorator with theme classes using globals.
So I modified the plugin code to additionally write the current dark mode state to the globals:
Storybook 8.0.2 storybook-dark-mode 4.0.1
In my storybook/angular, I use a global
componentWrapperDecorator
in my preview.ts:The story should be re-rendered every time the dark mode changes, but it doesn't.
Previously with Storybook 6, I fixed it by adding the following code to my preview.ts:
With Storybook 7, the
forceReRender()
has been removed. And with its replacementchannel.emit(FORCE_RE_RENDER);
, the class in the componentWrapperDecorator is not updated anymore.I tried several things, but nothing worked in all cases. Finally, I found this example of a global
componentWrapperDecorator
with theme classes using globals.So I modified the plugin code to additionally write the current dark mode state to the globals:
My decorator now looks like this:
By that, the stories are re-rendered with my decorator and the correct classes are applied on every change.
But the additional storage feels redundant and I'm wondering if there's a better way.
Thanks a lot in advance :-)