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

fix(useElementHover): support set el ref type #2079

Merged
merged 1 commit into from Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/useElementHover/demo.vue
Expand Up @@ -2,7 +2,7 @@
import { ref } from 'vue'
import { useElementHover } from '@vueuse/core'

const el = ref()
const el = ref<HTMLButtonElement>()
const isHovered = useElementHover(el)
</script>

Expand Down
2 changes: 1 addition & 1 deletion packages/core/useElementHover/index.ts
Expand Up @@ -3,7 +3,7 @@ import { ref } from 'vue-demi'
import type { MaybeComputedRef } from '@vueuse/shared'
import { useEventListener } from '../useEventListener'

export function useElementHover(el: MaybeComputedRef<EventTarget>): Ref<boolean> {
export function useElementHover(el: MaybeComputedRef<EventTarget | null | undefined>): Ref<boolean> {
const isHovered = ref(false)

useEventListener(el, 'mouseenter', () => isHovered.value = true)
Expand Down