Collection of essential Vue Composition Utilities
View on npmjs
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>