storybook: Cannot embed story in Docs MDX due to Angular component getting declared multiple times
Describe the bug
When embedding stories in a documentation page, switching between individual story pages and the docs page triggers errors on the console, and content fails to load on the documentation page:
Unhandled Promise rejection: Type ButtonComponent is part of the declarations of 2 modules: StorybookModule and StorybookModule! Please consider moving ButtonComponent to a higher module that imports StorybookModule and StorybookModule. You can also create a new NgModule that exports and includes ButtonComponent then import that NgModule in StorybookModule and StorybookModule.
Additional errors are present in the log immediately before this, not sure if they are significant or just a side effect of the other error:
Warning: render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.
ERROR Error: The selector "example-button--primary-jilgqplasf" did not match any elements
Unhandled Promise rejection: The selector "example-button--primary-jilgqplasf" did not match any elements
To Reproduce
https://github.com/ssams/storybook-angular-redeclared-comp
Setup with npx sb@next repro, adds a single documentation page (src/stories/Button.stories.mdx).
To trigger the error, open a single story page of the button component (URL path /?path=/story/example-button--primary), then navigate to the added docs page (/?path=/story/documentation-button--page).
System
Environment Info:
System:
OS: Linux 5.15 Fedora Linux 35 (Workstation Edition)
CPU: (8) x64 Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz
Binaries:
Node: 14.18.2 - /usr/bin/node
Yarn: 3.1.1 - /usr/local/bin/yarn
npm: 6.14.15 - /usr/bin/npm
Browsers:
Firefox: 96.0
npmPackages:
@storybook/addon-actions: ^6.5.0-alpha.19 => 6.5.0-alpha.19
@storybook/addon-docs: ^6.5.0-alpha.19 => 6.5.0-alpha.19
@storybook/addon-essentials: ^6.5.0-alpha.19 => 6.5.0-alpha.19
@storybook/addon-links: ^6.5.0-alpha.19 => 6.5.0-alpha.19
@storybook/angular: ^6.5.0-alpha.19 => 6.5.0-alpha.19
@storybook/builder-webpack5: ^6.5.0-alpha.19 => 6.5.0-alpha.19
@storybook/manager-webpack5: ^6.5.0-alpha.19 => 6.5.0-alpha.19
Additional context I was also able to reproduce the same issue with Storybook 6.4.13 and Angular 12.2.15.
Related to #15590 as it shows the same error message and may have the same root cause, however here it can be triggered via the Storybook-Docs Addon without even adding a new Story to the base project template. Note that using the legacy renderer via the parameter angularLegacyRendering: true does not solve the issue (stories are only rendered in the docs page in this case, but fail to load with different errors on the standalone story pages).
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 20 (5 by maintainers)
Setting
modernInlineRender: truesolved the problem for me as stated here: https://bytemeta.vip/repo/storybookjs/storybook/issues/18175Any news with this? I have the same problem
Sad, very sad. If there are any changes in this direction, please write in this thread.
I have tried multiple versions of addon-docs (6.4.19, 6.4.20, 6.5.0-alpha.59) and with each of them, I still get the same error. On which version did you get it fixed @sir-captainmorgan21 ?