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 ?
i typically do not but I don't use a ton of 3rd party libraries rn
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
so I guess my answer is "it depends" 😄
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.