B
B
bormor2020-10-01 13:56:51
JavaScript
bormor, 2020-10-01 13:56:51

Error "The client-side... DOM tree is not matching server-rendered content." when using v-if="!$apollo.loading". What is the possible reason?

Error when using nuxt-apollo module

client.js:730 [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.


While localizing it, I found out what appears when using v-if="!$apollo.loading"

What is the possible reason? How to correctly render TheHeader after loading data via Apollo?

Simplified example:
// dafault.vue
<template>
   <div>
      <!-- Если убрать v-if="!$apollo.loading" проблема пропадает -->
      <TheHeader v-if="!$apollo.loading" />
   </div>
</template>

<script>
import gql from 'graphql-tag';
import TheHeader from '~/components/TheHeader';

export default {
   components: {
      TheHeader,
   },

   apollo: {
      categories: {
         query: gql`
            query {
               categories {
                  id
                  label
                  url
               }
            }
         `,
         update: (data) => data.categories,
      },
   },
};
</script>

// TheHeader.vue
<template>
   <div>header</div>
</template>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question