Home

Issue: 1300

When in hash mode, initial components are not reused

[issue link]

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).

This bug report is available on Nuxt.js community (#c1150)