On this page
usePrevious
Category | Utilities |
---|---|
Export Size | 260 B |
Last Changed | 2 weeks ago |
Holds the previous value of a ref.
Usage
import { ref } from 'vue'
import { usePrevious } from '@vueuse/core'
const counter = ref('Hello')
const previous = usePrevious(counter)
console.log(previous.value) // undefined
counter.value = 'World'
console.log(previous.value) // Hello
Type Declarations
/**
* Holds the previous value of a ref.
*
* @see {@link https://vueuse.org/usePrevious}
*/
export declare function usePrevious<T>(
value: MaybeRefOrGetter<T>
): Readonly<Ref<T | undefined>>
export declare function usePrevious<T>(
value: MaybeRefOrGetter<T>,
initialValue: T
): Readonly<Ref<T>>
Source
© 2019-present Anthony Fu
Licensed under the MIT License.
https://vueuse.org/core/usePrevious/