KABBOUCHI / vue-tippy

VueJS Tooltip powered by Tippy.js
https://vue-tippy.netlify.app
MIT License
722 stars 86 forks source link

Props in render-function not reactive #305

Closed romastolbov closed 7 months ago

romastolbov commented 7 months ago
const list = ref([]);
const activeIndex = ref(0)

useTippy(triggerRef, {
  content: computed(() => {
    return h(ComponentList, {
      items: list.value,
      activeIndex: activeIndex.value, // always 0
      onHover: (value) => { activeIndex.value = value }
    })
  })

Why props items and activeIndex not reactive (not update in tooltip after onHover event) in component ComponentList?

KABBOUCHI commented 7 months ago

try defineComponent instead of computed

const list = ref([]);
const activeIndex = ref(0)

useTippy(triggerRef, {
  content: defineComponent(() => {
    return () => h(ComponentList, {
      items: list.value,
      activeIndex: activeIndex.value,
      onHover: (value) => { activeIndex.value = value }
    })
 })
KABBOUCHI commented 7 months ago
const list = ref([]);
const activeIndex = ref(0)

useTippy(triggerRef, {
  content: computed(() => {
    return h(ComponentList, {
      items: list.value,
      activeIndex: activeIndex.value, // always 0
      onHover: (value) => { activeIndex.value = value }
    })
  })

Why props items and activeIndex not reactive (not update in tooltip after onHover event) in component ComponentList?

fixed in 6.4.1, but better to use defineComponent

romastolbov commented 7 months ago
const list = ref([]);
const activeIndex = ref(0)

useTippy(triggerRef, {
  content: computed(() => {
    return h(ComponentList, {
      items: list.value,
      activeIndex: activeIndex.value, // always 0
      onHover: (value) => { activeIndex.value = value }
    })
  })

Why props items and activeIndex not reactive (not update in tooltip after onHover event) in component ComponentList?

fixed in 6.4.1, but better to use defineComponent

@KABBOUCHI Yes, everything is working as expected now, thank you so much for the quick response!