Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
/frameworkPublic archive

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

Merged
pi0 merged 3 commits into
mainfrom
fix/route-within-pages
Apr 6, 2022
Merged

fix(nuxt3): move new router behavior to useActiveRoute#4124
pi0 merged 3 commits into
mainfrom
fix/route-within-pages

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

resolvesnuxt/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.

@danielroedanielroe 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 pi0April 6, 2022 11:19
@danielroedanielroe self-assigned this Apr 6, 2022
@netlify

netlifyBot commented Apr 6, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt3-docs canceled.

NameLink
🔨 Latest commitf234ad4
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt3-docs/deploys/624d8b2c61a39e00087ab303

@misaon

Copy link
Copy Markdown
Contributor

Thanks @danielroe ! 👍🏼

@pi0

pi0 commented Apr 6, 2022

Copy link
Copy Markdown
Member

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.

@pi0pi0 changed the title fix(nuxt3): provide current route within children of pagesfix(nuxt3): move new router behavior to useActiveRouteApr 6, 2022
pi0
pi0 approved these changes Apr 6, 2022
@pi0
pi0 merged commit eb22ce9 into mainApr 6, 2022
@pi0
pi0 deleted the fix/route-within-pages branch April 6, 2022 12:45
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.xbugSomething isn't workingnuxt3❗ p4-importantPriority 4: bugs that violate documented behavior, or significantly impact perfpages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't access current route within page component setup

3 participants

@danielroe@misaon@pi0