Replies: 2 comments 4 replies
-
You can't load a module once, because each story is an independent Angular application. Not using inline rendering for the docs and maybe refreshing the preview iframe on each full render may be the only solution to totally prevent any global state from carrying over, but I don't have a snippet available to show how that could be done, at the moment. Based on the name of the module, I assume the global code that you refer to is registering webcomponents. If that is the case then you may be able to see some of the problems and potential workarounds with trying to deal with those in the comments on #25243. |
Beta Was this translation helpful? Give feedback.
-
Hi,
BUT, for Storybook, in the stories file, I called once
It seems to not destroy the injector for my webcomponents when I navigate in the stories. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The scenario is such that I'm registering the module in metadata in story decorator and now whenever the story is loaded in UI this module gets registered. It works fine when it is loaded for the first time but when I click on any other story and come back to this one , the module again gets registered ! (which I don't want bcz this module has certain code which shouldn't be triggered twice).
Hence, I need that the module be provided at global level which gets loaded once and is available too all the stories in storybook.
Please let me know , if anyone know how we can handle this. I'm not able to find any solution from the internet community regarding this.
Additional information
const meta: Meta = {
title: 'RadioGroup',
component: RadioGroupComponent,
decorators: [
moduleMetadata({
imports: [WebcomponentsModule],
}),
],
I want to provide this webComponentModule at global level instead of per story level and it shouldn't get triggered again when stories are switched rather it should get load one time only.
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions