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

Simplify the Composition API and avoid passing a ref #298

Open
edimitchel opened this issue Sep 18, 2023 · 2 comments
Open

Simplify the Composition API and avoid passing a ref #298

edimitchel opened this issue Sep 18, 2023 · 2 comments

Comments

@edimitchel
Copy link

edimitchel commented Sep 18, 2023

I take a look on the way tippy is used in Composition API, and I wondering if it could be simplified ?

Instead of creating and passing a target ref like:

<template>
  <button ref="btn">Tippy!</button>
</template>

<script setup>
import { useTippy } from 'vue-tippy'
import Counter from '@components/Counter.vue'

const btn = ref()

useTippy(btn, {
  content: h(Counter, { initialCount: 42 }),
  arrow: true,
})
</script>

... take the target returned by the composable and pass it to the dom:

<template>
  <button ref="btn">Tippy!</button>
</template>

<script setup>
import { useTippy } from 'vue-tippy'
import Counter from '@components/Counter.vue'

const { target: btn } = useTippy({
  content: h(Counter, { initialCount: 42 }),
  arrow: true,
})
</script>

The composable would be responsible to create the ref, then reassigned by Vue on mounting.

What do you think?

@KABBOUCHI
Copy link
Owner

maybe like this?

const { target: btn } = useTippy({
  content: h(Counter, { initialCount: 42 }),
  arrow: true,
})

@edimitchel
Copy link
Author

Yes sorry, I forgot to remove the btn param

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants