/vue-hook

Collection of essential Vue Composition Utilities

Primary LanguageTypeScript

@sanjeever/vue-hook

Collection of essential Vue Composition Utilities

Version

View on npmjs

Usage

For Vue3

npm i @sanjeever/vue-hook

without

<script setup lang="ts">
import { ref } from 'vue'

const divInstance = ref<HTMLDivElement>()
const clientHeight = divInstance.value?.clientHeight // <-- 'divInstance.value' is possibly 'undefined'.
</script>

<template>
  <div ref="divInstance" />
</template>

with

<script setup lang="ts">
import { useInstance } from '@sanjeever/vue-hook'

const divInstance = useInstance<typeof HTMLDivElement>()
const clientHeight = divInstance.value.clientHeight
</script>

<template>
  <div ref="divInstance" />
</template>