import { ref, watch } from 'vue' import type { Ref } from 'vue' const usePrevious = (state: Ref): T | undefined => { const innerState = ref() watch( () => state.value, (newVal, oldVal) => { innerState.value = oldVal } ) return innerState.value } export default usePrevious