How to use composition hook with ref to the component?
See original GitHub issueI get an error when I try to use a hook with a component
tippy() was passed a plain object which is not supported as an argument for virtual positioning. Use props.getReferenceClientRect instead.
And
DOMException: Failed to execute 'querySelectorAll' on 'Document': '[object Object]' is not a valid selector.
TheNavigation.vue
<template>
<div>
<BaseButton
label="Open dropdown"
ref="triggerElement"
/>
<div ref="contentElement">
Content
</div>
</div>
</template>
<script lang="ts">
import { defineComponent, ref } from '@vue/composition-api';
import { useTippy } from 'vue-tippy/composition';
import { BaseButton } from '@/components';
export default defineComponent({
components: {
BaseButton
},
setup() {
const triggerElement = ref(null);
const contentElement = ref(null);
const { tippy } = useTippy(triggerElement, {
content: contentElement,
placement: 'bottom',
animation: 'shift-away',
role: 'dropdown',
arrow: false,
trigger: 'click',
appendTo: 'parent',
interactive: true
});
return {
tippy,
triggerElement,
contentElement
};
}
});
</script>
BaseButton.vue
<template>
<button>
<slot>
{{ label }}
</slot>
</button>
</template>
<script lang="ts">
import { defineComponent } from '@vue/composition-api';
export default defineComponent({
props: {
label: {
type: String,
default: null
}
},
setup() {
return {};
}
});
</script>
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Refs and the DOM - React
Refs are created using React.createRef() and attached to React elements via the ref attribute. Refs are commonly assigned to an instance property when...
Read more >Advanced compositional React with useContext, useRef, and ...
Let's learn how to use React 16.8's hooks API to create a clean, compositional UI component. This article assumes you're familiar with hooks...
Read more >How to use $refs in Vue 3 with Composition API and Script ...
This post is going to explain how to use Ref in Vue 3, while using the Composition API and the Script Setup. The...
Read more >Vue 3 Composition API - "ref" and "reactive" - This Dot Labs
The Composition API provides two different ways to store data locally in the component - “ref” and “reactive”. These two methods serve a...
Read more >How to get $refs using Composition API in Vue3?
In my code I use Template Refs: ref is a special attribute, that allows us to obtain a direct reference to a specific...
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 Free
Top 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

I’ve released a new version
v4.10.0now you can mount/unmount manuallyhttps://kabbouchi.github.io/vue-tippy/4.0/features/composition-api.html?v4.10#example-6
https://github.com/KABBOUCHI/vue-tippy/blob/b803f1e9722342ca0a2948504a757d2ca054a8d2/docs/.vuepress/components/CompDemo6.vue#L1-L58
@negezor plz update to
v4.9.0and retryhttps://kabbouchi.github.io/vue-tippy/4.0/features/composition-api.html#example-5