question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Page component is created twice when navigating to it from page which uses different layout

See original GitHub issue

Environment

  • Operating System: Linux
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.8
  • Package Manager: npm@8.14.0
  • Builder: vite
  • User Config: modules, css, vite, runtimeConfig, build
  • Runtime Modules: @formkit/nuxt@1.0.0-beta.10
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-nodp3z?file=pages/page.vue

There are two pages and each of them uses a different layout. Just click on link to another page, then click on link to index page. You can see in console that index page component is created and mounted twice.

Describe the bug

If you are navigating using NuxtLink to another page which uses different layout, that page component is created twice.

Additional context

It started happening after upgrade from rc6 to rc7. Still happening on rc8.

I also noticed that await useAsyncData on rc6 does not block navigation when navigating to page with another layout. Layout shows without page, then after page data is loaded, page is mounted. This does not happen on rc7 and rc8, navigation is correctly blocked until data is fetched. Maybe it has something to do with this.

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:18
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

12reactions
vortechroncommented, Sep 1, 2022

this problem already exist in 2019 on nuxt 2, I never thought I’m facing this again on nuxt 3 😭😅

6reactions
MrWookcommented, Aug 24, 2022

@deanmikan We got around this with using the NuxtLayout component on every page and disable the layout in definePageMeta. For Example:

<template>
  <NuxtLayout name="default">
    <div>
      someCOntent
    </div>
  </NuxtLayout>
</template>
<script setup lang="ts">
definePageMeta({
  layout: false,
})
</script>

Its really painfull but at least the pages are working again on our site

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does every component in my page appears twice?
When I delete the router-view element, the components appear once but when I click on one of the links, it changes the URL...
Read more >
Aura component used twice in page
Aura component used twice in page - Salesforce Stack Exchange. Stack Overflow for Teams – Start collaborating and sharing organizational ...
Read more >
Tasks and the back stack | Android Developers
On this page; Lifecycle of a task and its back stack. Back press behavior for root launcher activities; Background and foreground tasks ...
Read more >
Strict Mode - React
When strict mode is enabled, React compiles a list of all class components using the unsafe lifecycles, and logs a warning message with...
Read more >
HTML: A good basis for accessibility - Learn web development
Page layouts. In the bad old days, people used to create page layouts using HTML tables — using different table cells to contain...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found