helix

2023-06-21T00:45:07.947889Z

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?

hifumi123 2023-06-21T01:15:48.335709Z

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

hifumi123 2023-06-21T01:16:35.121419Z

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

2023-06-21T01:19:57.369659Z

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

hifumi123 2023-06-21T01:21:58.268109Z

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"} ...))

2023-06-21T01:28:41.386289Z

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

hifumi123 2023-06-21T01:57:54.486879Z

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

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