Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt3): move new router behavior to useActiveRoute #4124

Merged
merged 3 commits into from
Apr 6, 2022

Conversation

danielroe
Copy link
Member

πŸ”— Linked issue

resolves nuxt/nuxt#13630

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Follow-up on #4092; users may legitimately wish to access current route within the page that is displaying. It doesn't make sense to suspend the route within the page that is loading, even if we do so elsewhere.

This PR provides the current route to the children of NuxtPage, exempting them from the suspension behaviour, meaning effectively useRoute only suspends the routes outside pages (e.g. in layouts or app.vue)...

An alternative/future approach would be to allow users to be in full control of this behaviour, perhaps allowing useRoute to take an option to enable the suspension behaviour for that route alone. Thoughts welcome.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working nuxt3 pages ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf labels Apr 6, 2022
@danielroe danielroe requested a review from pi0 April 6, 2022 11:19
@danielroe danielroe self-assigned this Apr 6, 2022
@netlify
Copy link

netlify bot commented Apr 6, 2022

βœ… Deploy Preview for nuxt3-docs canceled.

Name Link
πŸ”¨ Latest commit f234ad4
πŸ” Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/624d8b2c61a39e00087ab303

@misaon
Copy link
Contributor

misaon commented Apr 6, 2022

Thanks @danielroe ! πŸ‘πŸΌ

@pi0
Copy link
Member

pi0 commented Apr 6, 2022

There is too much overhead by injecting this way also makes useRoute behavior inconsistent. I propose that we introduce the new behavior of #4092 as the new useActiveRoute composable which changes after suspense.

@pi0 pi0 changed the title fix(nuxt3): provide current route within children of pages fix(nuxt3): move new router behavior to useActiveRoute Apr 6, 2022
@pi0 pi0 merged commit eb22ce9 into main Apr 6, 2022
@pi0 pi0 deleted the fix/route-within-pages branch April 6, 2022 12:45
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x bug Something isn't working nuxt3 ❗ p4-important Priority 4: bugs that violate documented behavior, or significantly impact perf pages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't access current route within page component setup
3 participants