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

ContentstackLivePreview.init() throws error when used in Nuxt 3 project #154

Closed
lsliwaradioluz opened this issue Jun 27, 2024 · 3 comments
Closed

Comments

@lsliwaradioluz
Copy link

lsliwaradioluz commented Jun 27, 2024

Hello team,

could you please help me figure out why this is happening? Seems to be a problem with post-robot and its sayHello function. Perhaps it's just a matter of bumping the post-robot version (you're using 8 whereas the latest one is 10).

FYI: In the reproduction steps, I am using a dynamic import because

import ContentstackLivePreview from '@contentstack/live-preview-utils';

yields the following error, even if I don't reference the ContentstackLivePreview anywhere

image

Steps to reproduce

Generate new Nuxt 3 project
npx nuxi@latest init --git-init false --package-manager yarn --dir test-project

Enter new project's directory
cd nuxt-app

Install Live Preview utils
yarn add @contentstack/live-preview-utils

Run your app
yarn run dev (and open the Live Preview window in Contentstack)

Dynamically import Live Preview in the app.vue component

<template>
  <div>
    <NuxtRouteAnnouncer />
    <NuxtWelcome />
  </div>
</template>

<script setup>
const isClient = typeof window !== 'undefined';
if (isClient) {
  const ContentstackLivePreview = await import('@contentstack/live-preview-utils');
  ContentstackLivePreview.init({ ssr: false });
}
</script>

see the following error:

image
@lsliwaradioluz
Copy link
Author

lsliwaradioluz commented Jun 27, 2024

FYI: The same error can be observed when I just import the postRobot and use it like this:

<template>
  <div>
    <NuxtRouteAnnouncer />
    <NuxtWelcome />
  </div>
</template>

<script setup>
import postRobot from 'post-robot';

const isClient = typeof window !== 'undefined';
if (isClient) {
  postRobot.on();
}
</script>
image

@erichuxohl
Copy link

Same problem here, @lsliwaradioluz were you able to solve the problem?

@contentstackMridul
Copy link
Contributor

Hello @lsliwaradioluz ,

We are pleased to inform you that the issue you reported has been addressed in version 2.0.4 of our live preview SDK. To resolve this problem, we kindly request that you update your SDK to version 2.0.4 or a more recent release.

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

No branches or pull requests

3 participants