Fork me on GitHub
#helix
<
2023-11-12
>
stagmoose15:11:32

I was reading this page: https://gist.github.com/lilactown/c0fd5d8df772412be79a034d627f8ff0 May I ask why this syntax ($ :mesh ... works? Can I find some intro of this on https://cljdoc.org/d/lilactown/helix why i don't need to refer the mesh component to the namespace? thanks!

hifumi12320:11:04

Strings and keywords are treated as "native elements"

stagmoose00:11:12

Thanks! I found what you said in cljdoc: "OR it is a keyword e.g. :div"

lilactown17:11:56

yeah. FWIW I would recommend not relying on this behavior, it may change in a future version of helix. Instead, I would create a specific macro that wraps $ that converts the kebab-case props to camelCase and other stuff.

🙌 1
stagmoose12:11:43

@U4YGF4NGM do you mean use ($ "xxx" ...) instead of ($ :xxx ...)

1
lilactown18:11:41

no, either one is fine. But when you pass a string or a keyword to $, there is some special behavior that happens right now: • it will convert kebab-case props like :on-click to camelcase onClick • it will convert the :style prop value to a JS object • it will rename special keys like :class to className and :for to :htmlFor This behavior may be removed in the future, as it's not general for all renderers; e.g. threejs may want different handling for :style than React Native. You can ignore this behavior by doing the pre-processing of :style yourself and ensuring keys passed to $ are already camelCase

👌 1
stagmoose01:11:59

got it! thanks!