Skip to content
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

TransitionGroup hydration mismatch #11514

Closed
fabkho opened this issue Aug 5, 2024 · 1 comment · Fixed by #11515
Closed

TransitionGroup hydration mismatch #11514

fabkho opened this issue Aug 5, 2024 · 1 comment · Fixed by #11515
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: ssr scope: transition

Comments

@fabkho
Copy link

fabkho commented Aug 5, 2024

Vue version

4.4.15

Link to minimal reproduction

https://stackblitz.com/edit/vue-ssr-example-9tg6p3?file=app.js

Steps to reproduce

Describe the Bug

A hydration mismatch occurs inside a TransitionGroup when a tag is rendered and there is an element with v-if inside.

[Vue warn]: Hydration children mismatch on <div>​…​</div>​ 
Server rendered element contains more child nodes than client vdom. 
  at <TransitionGroup tag="div">

Removing the tag still causes this warning:

[Vue warn]: Hydration node mismatch:
- rendered on server: <div>​…​</div>​  
- expected on client: Symbol(v-fgt) 
  at <TransitionGroup> 
  at <App>

Reproduction

To reproduce the issue in Vue SSR:

import { createSSRApp } from 'vue';

export function createApp() {
  return createSSRApp({
    data() {
      return {
        data: [
          { id: 1, name: 'Item 1' },
          { id: 2, name: 'Item 2' },
        ],
      };
    },
    template: `
      <div>
        <transition-group tag="div">
          <div v-for="(item, index) in data" :key="item.id">
            {{ item.name }}
          </div>
          <div v-if="false" :key="3"></div>
        </transition-group>
      </div>
    `,
  });
}

Observations:

  • The hydration mismatch occurs when using v-if inside a TransitionGroup with a tag specified.
  • Removing the tag causes a different but similar warning.

What is expected?

What is actually happening?

System Info

System:
    OS: macOS 14.3.1
    CPU: (12) arm64 Apple M2 Max
    Memory: 1.96 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.21 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.0/bin/npm
    pnpm: 9.0.6 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 127.0.6533.89
    Safari: 17.3.1

Any additional comments?

I have also reported this problem in the Nuxt repo: TransitionGroup hydration mismatch · Issue #28381 · nuxt/nuxt. In Nuxt, an additional hydration mismatch occurs when there is a comment inside the TransitionGroup, which should have been resolved here.

@edison1105
Copy link
Member

edison1105 commented Aug 5, 2024

a workaround <transition-group :tag="'div'">

yyx990803 pushed a commit that referenced this issue Aug 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: ssr scope: transition
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants