useMounted ​
Mounted state in ref.
Demo ​
unmounted
Usage ​
js
import { useMounted } from '@vueuse/core'
const isMounted = useMounted()
Which is essentially a shorthand of:
ts
const isMounted = ref(false)
onMounted(() => {
isMounted.value = true
})
Type Declarations ​
typescript
/**
* Mounted state in ref.
*
* @see https://vueuse.org/useMounted
*/
export declare function useMounted(): Ref<boolean, boolean>
Source ​
Contributors ​
Anthony Fu
yanbowen
Changelog ​
v12.0.0-beta.1
on 11/21/2024v10.10.0
on 5/27/2024v10.9.0
on 2/27/2024v10.8.0
on 2/20/2024v10.0.0-beta.3
on 4/12/20231aab1
- fix: check for the current instance