Skip to content

refManualReset

Category
Export Size
172 B
Last Changed
2 months ago

Create a ref with manual reset functionality.

Demo

Usage

ts
import { 
refManualReset
} from '@vueuse/core'
const
message
=
refManualReset
('default message')
message
.
value
= 'message has set'
message
.
reset
()
console
.
log
(
message
.
value
) // 'default message'

Type Declarations

ts
/**
 * Define the shape of a ref that supports manual reset functionality.
 *
 * This interface extends the standard `Ref` type from Vue and adds a `reset` method.
 * The `reset` method allows the ref to be manually reset to its default value.
 */
export interface 
ManualResetRefReturn
<
T
> extends
Ref
<
T
> {
reset
:
Fn
} /** * Create a ref with manual reset functionality. * * @see https://vueuse.org/refManualReset * @param defaultValue The value which will be set. */ export declare function
refManualReset
<
T
>(
defaultValue
:
MaybeRefOrGetter
<
T
>,
):
ManualResetRefReturn
<
T
>

Source

SourceDemoDocs

Contributors

Batuhan Baş
Vida Xie
phk422

Changelog

v14.2.0 on
13bbb - fix: add explicit return type annotation (#5246)
v14.0.0-alpha.2 on
81bb3 - feat: new function (#4644)

Released under the MIT License.

The new era of AI engineering.
Workflows, artifacts, and judgment that scale.
Request Early Access