Dynamically creating <NuxtLink> with <Component> no longer works
See original GitHub issueEnvironment
- Operating System:
Darwin
- Node Version:
v14.17.6
- Nuxt Version:
3.0.0-27454426.4cefce4
- Package Manager:
npm@8.5.4
- Bundler:
Vite
- User Config:
meta
,publicRuntimeConfig
- Runtime Modules:
-
- Build Modules:
-
Reproduction
https://stackblitz.com/edit/github-92nabt?file=app.vue
Describe the bug
Code like this used to work, but no longer does:
<Component :is="1 === 1 ? 'NuxtLink' : 'a'" to="/example">
This should be a link to the "Example" page
</Component>
Additional context
Two others with the same problem:
https://discord.com/channels/473401852243869706/897487139888062506/953235583403196476
https://discord.com/channels/473401852243869706/897487139888062506/953281246472056882
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:8 (2 by maintainers)
Top Results From Across the Web
How to create a dynamic nuxt-link with data fetched from a ...
Clicking on the login button correctly takes the app to the accountHandle page. However why is the URL incorrect? The Url after clicking...
Read more >Built-in Components - Nuxt
The linkActiveClass works the same as the vue-router class for active links. If we want to show which links are active all you...
Read more >How We Helped Bring You the New Nuxt 3 Link Component
With the new <NuxtLink> , we can now link to anything. We no longer have to choose between an anchor <a> tag or...
Read more >Dynamic Routing in Nuxt - DEV Community
Dynamic routing allows rendering your Vue components conditionally. ... Dynamic pages can be created when you don't know the name of the ...
Read more >Creating a Strapi Dynamic Zone & Rendering it in your Nuxt.js ...
In this tutorial, you will build a company website with Nuxt.js that ... for your component; Add a Text field (long text) and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The new way to pull in a component that is not globally registered is to use
resolveComponent
.See docs and this comment.
Example with NuxtLink.
Also ran into this. I very often have components that might or might not render a link, just like @przyb mentioned there. I might have a button component that does something like this:
Mostly I do this so that I don’t have to duplicate or spread other relevant button logic/styling between multiple components.
Another reason I might do something like this, is that part of the data might still be loading. I might know that I want to render a list of objects, but e.g. a component of the URL necessary to render the link is not available yet. Maybe client is still waiting for the rest of the data to load, or the data is only available after hydration but not server-side.