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

[2.14.0] Static Payload not applying to <nuxt-child> children components in some cases #7799

Closed
FreekVR opened this issue Jul 28, 2020 · 10 comments

Comments

@FreekVR
Copy link

FreekVR commented Jul 28, 2020

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

@flozero
Copy link
Contributor

flozero commented Aug 5, 2020

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

@honzabilek4
Copy link

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.

@elisiondan
Copy link

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();
  }

@stale
Copy link

stale bot commented Oct 4, 2020

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.

@stale stale bot added the stale label Oct 4, 2020
@FreekVR
Copy link
Author

FreekVR commented Oct 4, 2020

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

@agursoy
Copy link

agursoy commented Nov 5, 2020

I also faced this bug. Is there any update?

@stale
Copy link

stale bot commented Dec 6, 2020

Thanks for your contribution to Nuxt!
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.

@stale stale bot added the stale label Dec 6, 2020
@FreekVR
Copy link
Author

FreekVR commented Dec 6, 2020 via email

@stale stale bot removed the stale label Dec 6, 2020
@JustinRvt
Copy link

I'm so much following this as I'm experiencing the same issues.

For me, it appears that some variables are fetched, like {{article.name}} but if want to more in depth like {{article.image.formats.large.url}} I'll get a undefined on formats unless it as a parameter. Which works until I refresh and break everything to an apollo error 400.

Kind of annoying :/

@danielroe
Copy link
Member

Closed in #8466. Would appreciate testing via nuxt-edge to confirm fix.

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

No branches or pull requests

7 participants