tidy: refactor from use-callback to use-memo

This commit is contained in:
Sean Hagstrom 2024-04-01 18:28:05 +01:00 committed by Icaro Motta
parent 6fdb57a753
commit 5ff9097410
No known key found for this signature in database
GPG Key ID: 009557D9D014DF07
1 changed files with 9 additions and 6 deletions

View File

@ -76,12 +76,15 @@
(defn make-state-handler-factory [state-ref]
(let [storage (rn/use-memo #(atom {}) [state-ref])
factory (rn/use-callback
(memo storage
(fn [callback]
(print "make state handler")
(fn [event]
(callback @state-ref event))))
factory (rn/use-memo
(fn []
(fn [handler]
((memo storage
(fn [callback]
(print "make state handler")
(fn [event]
(callback @state-ref event))))
handler)))
[state-ref storage])]
{:factory factory
:storage storage}))