-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Open
Labels
bugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executiondifficulty: advancedIssues that are complex, e.g. large scoping for long-term maintainability.Issues that are complex, e.g. large scoping for long-term maintainability.
Milestone
Description
🐛 Bug Report
If more than one plugin enhances a theme component (https://docusaurus.io/docs/using-themes/#for-plugin-authors), such as docusaurus-theme-live-codeblock
, subsequent enhancers past the first will receive undefined
for the imported component to enhance from @theme-init
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
- Install the
@docusaurus/theme-live-codeblock
package - Activate it twice in docusaurus.config.js (to simulate more than one plugin enhancing
CodeBlock
):
themes: [
["@docusaurus/theme-live-codeblock", { id: "2" }],
["@docusaurus/theme-live-codeblock", { id: "1" }]
],
docusaurus start
- Receive errors in the console. This is caused by this import returning undefined for the second theme definition:
index.js?a908:1 Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. 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 `WrappedComponent`.
at WrappedComponent (webpack-internal:///./node_modules/@docusaurus/theme-live-codeblock/src/theme/CodeBlock/index.js:13:77)
at pre (webpack-internal:///../node_modules/@docusaurus/theme-classic/lib-next/theme/MDXComponents/index.js:12:598)
at MDXCreateElement (webpack-internal:///../node_modules/@mdx-js/react/dist/esm.js:153:30)
at wrapper (webpack-internal:///../node_modules/@mdx-js/react/dist/esm.js:148:25)
at MDXCreateElement (webpack-internal:///../node_modules/@mdx-js/react/dist/esm.js:153:30)
at MDXContent (webpack-internal:///./docs/optimize/dev/react/getting-started.mdx:12:1329)
<snip>
Expected behavior
You can have more than one theme enhancing a given component (i.e. the second theme instance would enhance the component enhanced by the first instance).
Actual Behavior
Importing the component after one enhancement gives undefined.
Your Environment
- Docusaurus version used: 2.0.0-alpha.72
- CodeSandbox + node 14, windows 10 + node 14
Reproducible Demo
Metadata
Metadata
Assignees
Labels
bugAn error in the Docusaurus core causing instability or issues with its executionAn error in the Docusaurus core causing instability or issues with its executiondifficulty: advancedIssues that are complex, e.g. large scoping for long-term maintainability.Issues that are complex, e.g. large scoping for long-term maintainability.