Skip to content

useMounted

Category
Export Size
122 B
Last Changed
2 weeks ago

Mounted state in ref.

Demo

Usage

ts
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

ts
/**
 * Mounted state in ref.
 *
 * @see https://vueuse.org/useMounted
 *
 * @__NO_SIDE_EFFECTS__
 */
export declare function 
useMounted
():
ShallowRef
<boolean, boolean>

Source

SourceDemoDocs

Contributors

Anthony Fu
SerKo
yanbowen

Changelog

v13.6.0 on
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
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.

Build faster with AI
New Masterclass to help you leverage AI in your Vue workflow
Get Early Access