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.9k stars 187 forks source link

Wormhole.hasTarget() not a function with Vue3 #401

Open cbloss opened 1 year ago

cbloss commented 1 year ago

Hey! I may be a complete blonde but I'm not seeing in the new Vue3 docs that Wormhole lost the method hasTarget. Has there been a change there? Here's what I got

 if (Wormhole.hasTarget('blockSettings')) {
    Wormhole.close({to: 'blockSettings'}, true)
  }

Ends up with: portal_vue__WEBPACK_IMPORTED_MODULE_0__.Wormhole.hasTarget is not a function

Thanks!!

kat3su commented 1 year ago

@cbloss Wormhole in portal-vue 3 is no longer Singleton so you need to inject it to your component to use.

<script setup>
const wormhole = useWormhole().
if (wormhole.transports.get('blockSettings')) { } // also worm hole no longer has `hasTarget`. Use `transports` instead
</script>
cbloss commented 11 months ago

Hey @kat3su ! Appreciate you reaching out but this still returns undefined. :(

image

When I console.log(wormhole.transports) the item is there but then when I wormhole.transports.get('blockSettings') it's undefined.