mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 00:01:51 -05:00
✨ Improve use-previous hook.
This commit is contained in:
parent
ede42e42b1
commit
ca52f4f8ea
1 changed files with 6 additions and 3 deletions
|
@ -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…
Add table
Reference in a new issue