UNPKG

@antdv/pro-utils

Version:

@antdv/pro-utils

16 lines (15 loc) 321 B
import { readonly, shallowRef, toRef, watch } from "vue"; function usePrevious(value, initialValue) { const previous = shallowRef(initialValue); watch( toRef(value), (_, oldValue) => { previous.value = oldValue; }, { flush: "sync" } ); return readonly(previous); } export { usePrevious };