LinusBorg / portal-vue

A feature-rich Portal Plugin for Vue 3, for rendering DOM outside of a component, anywhere in your app or the entire document. (Vue 2 version: v2.portal-vue.linusb.org)
http://portal-vue.linusb.org
MIT License
3.89k stars 188 forks source link

injection "Symbol(wormhole)" not found #400

Open hackel opened 1 year ago

hackel commented 1 year ago

I'm upgrading a vue2 app to vue3 and running into a problem with PortalVue. The app is creating a PortalTarget inside of a Bootstrap-Vue modal confirmation dialog (dynamically created):

            return this.$bvModal.msgBoxConfirm(
                this.$createElement('PortalTarget', {
                    props: {
                        name: this.$id('ConnectModal'),
                        slotProps: {
                            accounts: accountNames,
                            account: accountName,
                            single: isSingle,
                        },
                    },
                }),
                {
                    title: `Send Invite to ${isSingle ? accountName : 'Subscribers'}`,
                    cancelVariant: 'link',
                    okTitle: 'Assign Rates',
                    okVariant: 'success',
                },
            );

This gives me an error that "resolveComponent can only be used in setup() or render()," so I imported the PortalTarget component and used it directly, and that's when I get the error mentioned in the subject.

[Vue warn]: injection "Symbol(wormhole)" not found.
[portal-vue]: Necessary Injection not found. Make sur you installed the plugin properly.

I'm sure PortalVue is installed correctly. I've also tried using resolveComponent in the setup function and returning it from there, but I get the same error. This was all working fine with PortalVue 2.x. Is there any reason that creating the PortalTarget component dynamically like this would not work in PortalVue 3?