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
In Storybook v9 (rc.4), stories using NextJs page that imports MDX as the testing component would fail to be run in CLI mode, which worked on Storybook v8.
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `MDXContent`.
Context:
This might be something related to import and export as mentioned in #5013 (comment). When NextJs pages which import MDX contents are imported by the stories (page.stories.tsx --> page.tsx --> doc.mdx), Storybook v9 has some problems to handle the MDX import in CLI mode, and the error above occurs. The same stories worked in Storybook browser mode and Storybook v8 (both browser mode and CLI mode).
The MDX page doesn't have an explicit export, so I think it is using default export handled by the MDX plugins.
Please check the reproduction link below for a minimal reproduction example, the tests passed on browser mode (pnpm storybook) but failed on CLI mode running through Vitest (pnpm test).
The branch storybook-v8 has the working version with storybook v8, specifically this is the diff between v8 and v9.
CHC383
changed the title
[Bug]: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
[Bug][v9]: Fail to import/render MDX
May 24, 2025
@shilman Yes I do, please see the reproduction link
CHC383
changed the title
[Bug][v9]: Fail to import/render MDX
[Bug][v9 Regression]: Storybook fail to run story with NextJs page that imports/renders MDX in CLI mode
May 27, 2025
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
In Storybook v9 (rc.4), stories using NextJs page that imports MDX as the testing component would fail to be run in CLI mode, which worked on Storybook v8.
Context:
This might be something related to import and export as mentioned in #5013 (comment). When NextJs pages which import MDX contents are imported by the stories (
page.stories.tsx
-->page.tsx
-->doc.mdx
), Storybook v9 has some problems to handle the MDX import in CLI mode, and the error above occurs. The same stories worked in Storybook browser mode and Storybook v8 (both browser mode and CLI mode).The MDX page doesn't have an explicit export, so I think it is using default export handled by the MDX plugins.
Please check the reproduction link below for a minimal reproduction example, the tests passed on browser mode (
pnpm storybook
) but failed on CLI mode running through Vitest (pnpm test
).The branch
storybook-v8
has the working version with storybook v8, specifically this is the diff between v8 and v9.Reproduction link
https://github.com/CHC383/storybook-mdx-debug
Reproduction steps
pnpm i
pnpm test
System
Additional context
No response
The text was updated successfully, but these errors were encountered: