-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warn Hydration completed but contains mismatches.
and Custom components are not rendered
#1918
Comments
I could reproduce the issue on my system. It is working if you manually import your component inside your
|
The problem seems to be caused by the semicolon at the end of the sentence. I have fixed the bug after removing semicolon. |
Sorry, my fault. I reproduce the bug. The bug cannot be fixed by removing semicolon. |
Here I come again! I have resolved this bug by registering global component. Don't import components in markdown. I think there is an unknown bug. |
Also, for insurance purposes, don't use any HTML tag in markdown. |
Could you show me an example? |
Remove all code contain "import" in markdown. And registry component in ".vitepress/theme/index.js", the config as below: import DefaultTheme from 'vitepress/theme';
import SourceCodeExample from '../../scripts/SourceCodeExample.vue';
export default {
...DefaultTheme,
enhanceApp(ctx) {
DefaultTheme.enhanceApp(ctx);
// registry global component
ctx.app.component('SourceCodeExample', SourceCodeExample);
},
setup() {},
};
|
Thank you very much! |
Describe the bug
When markdown file is added
<script>
, the custom component does not work properly and an error is reported with the error messageHydration completed but contains mismatches.
.Reproduction
Demo repo: https://github.com/stevending1st/vitepress-hydration-bug-report
Here are three markdown files, all of which introduce custom components.
When I execute
pnpm dev
(vitepress dev website
), accessing/test-1
,/test-2
,/test-3
works fine.When I execute
pnpm build && pnpm preview
(vue-tsc && vitepress build website && vitepress preview website
), visit/test-1
,/test-2
,/test-3
, my custom component does not work properly and the F12 console reportsHydration completed but contains mismatches.
.Expected behavior
When I add the valid
<script>
and executevue-tsc && vitepress build website && vitepress preview website
, the custom components will display normally and the console will not report an error.System Info
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: