Skip to content

useMounted

Category
Export Size
114 B
Last Changed
2 months ago

Mounted state in ref.

Demo

mounted

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(): ShallowRef<boolean, boolean>

Source

SourceDemoDocs

Contributors

Anthony Fu
yanbowen

Changelog

v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v10.10.0 on
7966b - fix: The second argument in vue2.7 should be undefined (#3830)
v10.9.0 on
ee297 - fix: compatible with vue2.7 (#3802)
v10.8.0 on
2f66e - fix: hold the instance, close #3785, close #3795
v10.0.0-beta.3 on
1aab1 - fix: check for the current instance

Released under the MIT License.

Save 37% on one year of learning Vue, Includes the Vue.js Master Class.
Get Offer