Skip to content

Hot reload fails when using Import wrappers #96

Open
@paulnta

Description

@paulnta

I have a Nuxt project and I'm trying to understand why import wrappers such as hydrateWhenVisible don't work well with hot reload. When I edit a lazy hydrated component, some errors are triggered and the component seems to lose its props.

Steps to reproduce:
You can use this codesandbox: https://codesandbox.io/s/vue-lazy-hydration-hot-reload-issue-vfrpm

  • No problem when editing pages/index.vue
  • But editing HelloWorld.vue will trigger the following errors (you may have to edit the template a few times before it fails)
    Cannot read property 'message' of undefined
    Failed to execute 'unobserve' on 'IntersectionObserver'
    

pages/index.vue

<template>
    <HelloWorld :content="{ message: 'hello world' }" />
</template>

<script>
import { hydrateWhenVisible } from "vue-lazy-hydration";

export default {
  components: {
    HelloWorld: hydrateWhenVisible(() => import("~/components/HelloWorld")),
  },
};
</script>

components/HelloWorld.vue

<template>
  <div>
    <h1>{{ content.message }}</h1>
    <!-- Editing this template will fail on hot reload: `content` is undefined -->
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  props: {
    content: Object,
  },
};
</script>

Thanks in advance 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions