tidy: refactor from use-callback to use-memo

This commit is contained in:
Sean Hagstrom 2024-04-01 18:28:05 +01:00
parent 26d615da36
commit b207c2e790
No known key found for this signature in database
GPG Key ID: 5257FEDF56307320
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}))