This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-20
Channels
- # announcements (33)
- # aws (1)
- # babashka (8)
- # beginners (100)
- # calva (59)
- # clara (4)
- # clj-kondo (33)
- # cljdoc (9)
- # cljs-dev (30)
- # cljsrn (1)
- # clojure (28)
- # clojure-australia (1)
- # clojure-boston (1)
- # clojure-dev (4)
- # clojure-europe (14)
- # clojure-france (5)
- # clojure-italy (7)
- # clojure-nl (1)
- # clojure-uk (36)
- # clojurescript (13)
- # clojureverse-ops (6)
- # conjure (2)
- # cursive (2)
- # datahike (11)
- # datalevin (1)
- # datomic (106)
- # graphql (3)
- # helix (10)
- # holy-lambda (24)
- # kaocha (2)
- # lambdaisland (3)
- # lsp (199)
- # malli (35)
- # off-topic (16)
- # pathom (7)
- # polylith (38)
- # portal (16)
- # quil (2)
- # re-frame (18)
- # reagent (57)
- # shadow-cljs (11)
- # testing (3)
- # xtdb (9)
Hi folks, is it ok to use ->clj from cljs-bean.core on a helix component to destructure a javascript react hook ?
(defnc Origem
[]
(let [
[is-dragging drag drag-preview]
(->clj
(useDrag
(fn []
#js {:type "BOX"
:collect (fn [monitor]
; (.log js/console monitor)
#js {:isDragging (gobj/get monitor "isDragging")})
})))
]
))
I know it's a bit off topic, but helix comes with cljs-bean and the point of helix + shadow is consume the libraries without wrappers, so I'm asking, when you interact with js hooks do you use cljs-bean ?
you can destructure arrays, so the only reason you would do this is for cljs-bean's recursive conversion of drag
and drag-preview
into CLJS-like data. I don't know what those are normally, so I don't know if I would use bean with it or not
one thing that ->clj
is going to do is create a new reference every render. that might break memoization somewhere else, where it expects the reference to be stable.
in that case, what I would suggest is creating a custom hook use-drag
that memoizes the ->clj
to happen only when the values returned by useDrag
change.
ultimately every library and case can be different so I don't have an "I always do this" or "I never do this." sorry!
@lilactown Thank you, that's the guidance I was looking for.