composition-api icon indicating copy to clipboard operation
composition-api copied to clipboard

bug: useAsync don't work in SSR

Open TianbinTobin opened this issue 3 years ago • 0 comments

🐛 The bug useAsync in nuxt-composition-api don't work with SSR

🛠️ To reproduce Steps to reproduce the behavior:

  1. set babel in nuxt.config.ts
babel: {
      presets({ isServer }) {
        const targets = isServer ? { node: 'current' } : { browsers: ['last 2 versions'], ie: 11 };
        return [['@nuxt/babel-preset-app', { corejs: { version: 3 }, targets }]];
      },
      plugins: [['@babel/plugin-transform-runtime', { regenerator: true }]],
    },
  1. create a page component
<script lang="ts">
import { defineComponent, useAsync } from '@nuxtjs/composition-api';

export default defineComponent({
  name: 'LiveDashboard',
  setup() {
    useAsync(() => {
      console.log('useAsync');
    });

    return {};
  },
});
</script>
  1. See error image

TianbinTobin avatar Dec 17 '21 06:12 TianbinTobin