Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive components support #1174

Closed
danyadev opened this issue May 12, 2020 · 6 comments
Closed

Recursive components support #1174

danyadev opened this issue May 12, 2020 · 6 comments

Comments

@danyadev
Copy link

danyadev commented May 12, 2020

Version

3.0.0-beta.12

Reproduction

https://jsfiddle.net/posva/g04vta1f/

Steps to reproduce

  1. Run fiddle
  2. check console

What is expected?

Сomponents are rendered.

What is actually happening?

Warn in console: Failed to resolve component: Foo


The problem is reproduced if you use import Foo from './Foo.vue';

If you try the example from edge cases for vue 2, then another error will occur: Invalid VNode type: undefined (undefined).

// Foo.vue
<script>
export default {
  components: {
    Bar: () => import('./Bar.vue')
  }
};
</script>
@posva
Copy link
Member

posva commented May 13, 2020

Updated to add a reproduction. Hopefully, you will use that fiddle to create a reproduction in the future 🙂

@LinusBorg
Copy link
Member

LinusBorg commented May 13, 2020

components: { 
  Bar: () => Promise.resolve(Bar)
},

This is not a valid component definition. async components need to be wrapped with defineAsyncComponent() in Vue 3.

components: { 
  Bar: defineAsyncComponent(() => Promise.resolve(Bar))
},

Updated, working Fiddle: https://jsfiddle.net/9x2owt7m/

@danyadev
Copy link
Author

Oh, using import makes the component load separately, and this is noticeable when the component is first rendered, but I don’t need it

image

@danyadev
Copy link
Author

In vue 2.x, I globally registered recursive components, but on version 3.x I do not know how to do this

@posva
Copy link
Member

posva commented May 15, 2020

You can do

let app = createApp(App)
app.component('Recursive', Recursive)

@danyadev
Copy link
Author

Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants