vuejs / pinia

🍍 Intuitive, type safe, light and flexible Store for Vue using the composition api with DevTools support
https://pinia.vuejs.org
MIT License
12.72k stars 996 forks source link

Nuxt3 useRoute update #2670

Closed gyxoBka closed 2 months ago

gyxoBka commented 2 months ago

Reproduction

https://stackblitz.com/edit/nuxt-starter-h3pnwf?file=stores%2Flocation.ts

Steps to reproduce the bug

  1. Go to Other page id 1 You'll see that all id's are 1

  2. Then go to Main Page

  3. Then go to Other page id 2 You'll see that all id's are 2 except first. Location Outside wiill be still 1

Expected behavior

The query should be updated when router defined outside a method

Actual behavior

it is updated only when declaring a variable inside the method during auto-import or when importing from vue-router

Additional information

No response

posva commented 2 months ago

This seems related to Nuxt, not pinia. BTW, the inside usage is not correct, useRoute() shouldn't be called within methods (like any composable)