Nuxt.js: [2.14.0] Static Payload not applying to <nuxt-child> children components in some cases

Created on 28 Jul 2020  路  6Comments  路  Source: nuxt/nuxt.js

May be related to #7791

Nuxt payloads do not always apply correct in generated apps with target: static, if nuxt-child is used, and both a child component of the higher-level component, and one of the children of nuxt-child implement fetch() (see diagram below)

Versions

  • nuxt: 2.14.0
  • node: 10.23.0

Reproduction

Source: https://github.com/FreekVR/nuxt-static-repro/tree/nested-fetch-issues

Demo: https://wonderful-ardinghelli-e41a6b.netlify.app/magazine/category/bar/

This will have correctly generated data on first (hard) load, but clicking the link-links present on the page will show that in SPA mode, the payload data is not applying afterwards.

This seems to be caused by the fetch() in this component, which is included in the nuxt-child parent component.

Steps to reproduce

Have an application implementing a structure like below (see repro source for practical implementation)

image

What is Expected?

Data is correctly applied from the payload when navigating through SPA links

What is actually happening?

Data is not applied / lost

bug-report

Most helpful comment

I can confirm that this issue still persists with the latest release, unfortunately.

All 6 comments

Same error here. I will try to give more infos and another example repo soon too.

I can confirm the issue, same behaviour as stated in description.
The page is generated correctly, even the payload data exist, but when navigating using <nuxt-link> the nested fetch hook is not being invoked.

Until this issue is resolved, we've opted for calling fetch in beforeMounted hook which seems to work properly with the static target.

  async fetch () {
    // fetching data
  },
  async beforeMount () {
    await this.$fetch();
  }

Thanks for your contribution to Nuxt.js!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you would like this issue to remain open:

  1. Verify that you can still reproduce the issue in the latest version of nuxt-edge
  2. Comment the steps to reproduce it

Issues that are labeled as pending will not be automatically marked as stale.

I can confirm that this issue still persists with the latest release, unfortunately.

I also faced this bug. Is there any update?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VincentLoy picture VincentLoy  路  3Comments

mikekidder picture mikekidder  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

vadimsg picture vadimsg  路  3Comments

surmon-china picture surmon-china  路  3Comments