Skip to content

usePrevious

Category
Export Size
141 B
Last Changed
5 days ago

Holds the previous value of a source

Demo

Usage

tsx
import { 
usePrevious
} from '@reause/core'
const
previous
=
usePrevious
(counter) // `undefined` until the first change
// after each change, `previous` is the value the source had before it

Type Declarations

ts
export function usePrevious<T>(value: T): T | undefined

export function usePrevious<T>(value: T, initialValue: T): T

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
5308e - fix(core): resolve usePrevious audit findings (#626)
8fddc - chore!: remove all Vue-only Maybe* types and getter unions, adopt React Ref (#462)

Released under the MIT License. v0.1.8