mirror of
https://github.com/robonen/tools.git
synced 2026-03-20 10:54:44 +00:00
feat(monorepo): migrate vue packages and apply oxlint refactors
This commit is contained in:
30
vue/toolkit/src/composables/lifecycle/useMounted/index.ts
Normal file
30
vue/toolkit/src/composables/lifecycle/useMounted/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { onMounted, readonly, ref } from 'vue';
|
||||
import type { ComponentInternalInstance } from 'vue';
|
||||
import { getLifeCycleTarger } from '@/utils';
|
||||
|
||||
/**
|
||||
* @name useMounted
|
||||
* @category Lifecycle
|
||||
* @description Returns a ref that tracks the mounted state of the component (doesn't track the unmounted state)
|
||||
*
|
||||
* @param {ComponentInternalInstance} [instance] The component instance to track the mounted state for
|
||||
* @returns {Readonly<Ref<boolean>>} The mounted state of the component
|
||||
*
|
||||
* @example
|
||||
* const isMounted = useMounted();
|
||||
*
|
||||
* @example
|
||||
* const isMounted = useMounted(getCurrentInstance());
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
export function useMounted(instance?: ComponentInternalInstance) {
|
||||
const isMounted = ref(false);
|
||||
const targetInstance = getLifeCycleTarger(instance);
|
||||
|
||||
onMounted(() => {
|
||||
isMounted.value = true;
|
||||
}, targetInstance);
|
||||
|
||||
return readonly(isMounted);
|
||||
}
|
||||
Reference in New Issue
Block a user