UNPKG
@hanxx/vue-hooks
Version:
latest (1.1.1)
1.1.1
1.1.0
1.0.2
1.0.1
⚡️ Awesome Vue Hooks
github.com/lianghx-319/vue-hooks
lianghx-319/vue-hooks
@hanxx/vue-hooks
/
esm
/
usePrevious.js
9 lines
(8 loc)
•
226 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
import
{ ref, watch }
from
'@vue/composition-api'
;
export
default
function
usePrevious
(
state
) {
var
previous =
ref
();
watch
(state,
function
(
_, oldVal
) { previous.
value
= oldVal; });
return
previous; }