Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/refManualReset.md
1---2category: Reactivity3---45# refManualReset67Create a ref with manual reset functionality.89## Usage1011```ts12import { refManualReset } from '@vueuse/core'1314const message = refManualReset('default message')1516message.value = 'message has set'1718message.reset()1920console.log(message.value) // 'default message'21```2223> [!NOTE]24> `refManualReset` is shallow, which may cause your UI not updated on value changes.25> Wrap your value with `reactive` can achieve deep reactivity, but this workaround may not suit all use cases.2627## Type Declarations2829```ts30/**31* Define the shape of a ref that supports manual reset functionality.32*33* This interface extends the standard `Ref` type from Vue and adds a `reset` method.34* The `reset` method allows the ref to be manually reset to its default value.35*/36export interface ManualResetRefReturn<T> extends Ref<T> {37reset: Fn38}39/**40* Create a ref with manual reset functionality.41*42* @see https://vueuse.org/refManualReset43* @param defaultValue The value which will be set.44*/45export declare function refManualReset<T>(46defaultValue: MaybeRefOrGetter<T>,47): ManualResetRefReturn<T>48```49