mirror of
https://github.com/penpot/penpot.git
synced 2026-05-15 13:04:25 +00:00
✨ Improve use-previous hook.
This commit is contained in:
parent
ede42e42b1
commit
ca52f4f8ea
@ -218,8 +218,11 @@
|
||||
#(rx/dispose! sub)))))
|
||||
|
||||
;; https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
|
||||
(defn use-previous [value]
|
||||
(let [ref (mf/use-ref)]
|
||||
(defn use-previous
|
||||
[value]
|
||||
(let [ref (mf/use-ref value)]
|
||||
(mf/use-effect
|
||||
#(mf/set-ref-val! ref value))
|
||||
(mf/deps value)
|
||||
(fn []
|
||||
(mf/set-ref-val! ref value)))
|
||||
(mf/ref-val ref)))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user