question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SSR mismatch using b-dropdown with slot

See original GitHub issue

Hello,

When using b-dropdown with a custom slot, like this (straight from the doc) :

<b-dropdown variant="link" size="lg" no-caret>
	<template slot="button-content">
		Click Me !
	</template>
	<b-dropdown-item to="/whatever">
		Link 1
	</b-dropdown-item>
	<b-dropdown-item to="/nowhere">
		Link 2
	</b-dropdown-item>
</b-dropdown>

I get the following SSR error :

[Vue warn]: The client-side rendered virtual DOM tree is not matching server-rendered content. This is likely caused by incorrect HTML markup, for example nesting block-level elements inside <p>, or missing <tbody>. Bailing hydration and performing full client-side render.

Environment:

  • macOS 10.13
  • nuxt 2.3.4
  • bootstrap-vue 2.0.0-rc.11

Is there a workaround ? Thanks ! 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tmorehousecommented, Nov 5, 2019

@jschoedt

There are issues with your markup.

You are telling list-group-item to render as a <button> element (via the button prop), and then placing a dropdown inside of that <button> (which the dropdown includes a <button>, as well as other content not allowed inside of that list group button <button>). So it is creating invalid HTML markup (you can’t have a <button> inside of another <button>), which the browser is “fixing” when it tries to hydrate. SRR blindly renders the invalid markup, but the browser when it sees that markup is removing things that aren’t allowed in the button (or placing bits outside of the button).

Use markup similar to below to get valid HTML markup:

<template>
  <b-list-group >
    <b-list-group-item class="p-0">
      <b-dropdown variant="link" no-caret text="DDown" class="w-100" toggle-class="text-left">
        <b-dropdown-item-button >
          Edit
        </b-dropdown-item-button>
      </b-dropdown>
    </b-list-group-item>
  </b-list-group>
</template>
0reactions
jschoedtcommented, Nov 5, 2019

You are right. Thanks for pointing that out. Removing the button attribute fixed it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSR and keep-alive issue in Vue 3: dynamic component
Hydration completed but contains mismatches. What shall I do to fix this issue? javascript · vue.js · server-side-rendering ...
Read more >
Removing and replacing a memory module (IBM SSR task)
You can remove and replace a faulty dual in-line memory module (DIMM) from a control enclosure. You can also use this procedure to...
Read more >
Server side rendering - Radix UI
Server side rendering or SSR , is a technique used to render components to HTML on the server, as opposed to rendering them...
Read more >
A deep analysis into isomorphic, autonomous cross ... - ITNEXT
Nested components have to be slotted (as described above) and are therefore NOT inside of the rendering path of the parent component but...
Read more >
@vue/server-renderer | Yarn - Package Manager
... you no longer need to explicitly install this package and ensure its version match that of vue 's. Just use the vue/server-renderer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found