helix 2023-06-21

Hi, folks! How do you perceive the use of "class" (from the Reagent world) compared to "className" from the React world, and its relationship with Helix components? I suspect that you standardized on "class" because it's not a reserved word, requires less typing, and aligns with Reagent's conventions. If not, why? What are the pros and cons that you have discovered?

:class is not automatically renamed to :className unless your code goes down the dom-props path, which is done only with β€œnative” elements

that is to say, ($ component {:class "c"}) will only rename :class to :className if component is either a string, keyword, or symbol with ^:native metadata attached

@hifumi123 when you design a component do you use class or className ?

if native, I write :class for brevity, otherwise :className e.g.

(defnc thing-with-mui-box []
  ($ Box {:className "c"} ...))

(defnc thing-with-div []
  (d/div {:class "c"} ...))

what about your variable parameter (defnc MyComponent [class | className | class-name ])

helix components are always [props ref], if I am destructuring the props, then I would probably use class

πŸ‘ 1
πŸ‘πŸ» 1