Static GitHub Issues

[1300] When in hash mode, initial components are not reused

prev: How do I use the koa template 'asyncData' request to get the session
next: how to catch nuxt error like this

In hash router mode, route component instances that participate in initial load are not reused, and are getting destroyed and recreated when going from e.g. /items/1 to /items/2.

Nuxt version: 1.0.0-rc.3, but happens in 0.10.7 too.

E.g. the following route structure:

{
  path: '/items',
  component: Items, // `Items` has mounted and beforeDestroy hook
  children: [
    { path: ':id', component: Item }, // `Item` has mounted and beforeDestroy hook
  ],
}

Expected: 1. Go to /items/1. 2. Refresh the page, see mounted called for both components. 3. Go to /items/2, see no hooks called (instances are reused).

Actually happens: 1. Go to /items/1. 2. Refresh the page, see mounted called for both components. 3. Go to /items/2, see beforeDestroy and then mounted called for both components. 4. Go to /items/3, see no hooks called (instances are reused).

Repro: https://github.com/simplesmiler/nuxt-issue


Likely the issue is either with normalizeComponents or when it happens (or does not happen).

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This bug report is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1150">#c1150</a>)</em></sub></div>