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

SSR using data-twic-background attribute cause hydratation mismatch because of twic-background-done class #91

Open
existe-deja opened this issue Jan 31, 2024 · 3 comments
Labels
question Further information is requested

Comments

@existe-deja
Copy link

component: nuxt3
version: 0.27.1

On nuxt3, during SSR I have a hydration class mismatch caused by tthe removal of twic-background-done

Exemple of warning message

[Vue warn]: Hydration class mismatch on 
<div class="h-full min-h-[160px] bg-…er twic-background-done" data-twic-background="url('image:/XXX.jpg')" data-twic-step="50" data-v-inspector="components/XXX.vue:17:5" style='background-image: url("h…twic=v1/cover=300x163");'>
 
  - rendered on server: class="h-full min-h-[160px] bg-cover bg-center twic-background-done"
  - expected on client: class="h-full min-h-[160px] bg-cover bg-center"
  Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
  You should fix the source of the mismatch.

Exemple of component causing errors

    <div
      v-if="srcImage"
      :data-twic-background="`url('image:${srcImage}')`"
      data-twic-step="50"
      class="h-full min-h-[160px] bg-cover bg-center"
    />
@mbgspcii
Copy link
Collaborator

Hi @existe-deja

I confess that I don't fully understand. I'm having difficulty recognizing the code generated by the TwicPics components.

Can you confirm that you are using one of TwicImg, TwicVideo or TwicPicture ?

In any case, it sounds like a problem we've encountered on Next.

Thanks for the issue.

We'll keep you informed.

@mbgspcii mbgspcii added the question Further information is requested label Jan 31, 2024
@jaubourg
Copy link
Member

From what I can gather, @existe-deja is using script attributes directly. In that particular instance, to handle a background image, something TwicPics components do not provide at the moment. I suspect the script is installed before hydration and it starts handling the element right away before Nuxt has a chance to check the HTML structure. I'm surprised we didn't see Hydration errors on our end.

@existe-deja are you, by any chance, installing the script manually? The TwicPics components will install the script for you (since they use it internally) and it should do so in a timely fashion.

@existe-deja
Copy link
Author

Hi, thanks for your answers.

@jaubourg you're right, I'm using the data-twic-background functionality.
I decided to write an issue because I read the changelog few days ago and it was mentioning hydratation issue with Next.

Twicpics is installed with the provided nuxt3 module. I'll post you a minimal reproduction setup asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants