reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
Audrius 2021-06-02T06:13:22.050400Z

hi! what this :f> means in Reagent?

Schpaa 2021-06-02T07:07:17.051Z

Render a function component

Pepijn de Vos 2021-06-02T14:01:19.051600Z

Welp... I need to have an actual hyphenated property but reagent converts it to camelcase. what to do?

juhoteperi 2021-06-02T14:08:10.051700Z

What is the case where you need this? React needs camelCase for all element properties. data- and aria- properties are special case, and should be ignored by Reagent.

juhoteperi 2021-06-02T14:09:54.052100Z

Or hmm... nowadays React just uses "unknown" properties as is: https://reactjs.org/blog/2017/09/08/dom-attributes-in-react-16.html IIRC Reagent won't touch the key if you use string as key. [:div {:on-click "this key will be converteted" :data-foo "data- property names aren't converted" "string-key-foo-bar" "this key is used as is"} ...]

juhoteperi 2021-06-02T14:11:02.052400Z

Yeah reagent will convert just keyword and symbols to camelCase: https://github.com/reagent-project/reagent/blob/master/src/reagent/impl/template.cljs#L48-L55

juhoteperi 2021-06-02T14:55:32.053300Z

https://reactjs.org/docs/dom-elements.html#all-supported-html-attributes React doesn't directly support that property, but should work as-is if you use string as properties map key.

juhoteperi 2021-06-02T14:55:44.053600Z

[:g {"render-order" 5} ...]

juhoteperi 2021-06-02T14:58:00.054Z

Hmm, I wonder if render-order was ever implemented in browsers? That spec is just a draft, and searches don't return anything.

Pepijn de Vos 2021-06-02T15:02:45.054700Z

Yea it doesn't appear to be working very well haha

az 2021-06-02T20:52:34.059400Z

Hi all, is there a way to serialize hiccup with a custom component? Not sure how to get

[:div 
 [foo.bar/custom-component]]
to render from deserialization. Any tips?

emccue 2021-06-02T22:33:59.060200Z

@limix If all you are sending is the symbol, you need to walk the hiccup and replace the symbols with the references they should point to

emccue 2021-06-02T22:34:57.061500Z

its a bit tedious, but if you keep a map at runtime of symbol name -> function (basically reifying the namespace) it shouldn't be too bad

emccue 2021-06-02T22:35:04.061800Z

think something like

emccue 2021-06-02T22:35:49.062800Z

(def serializable-components (atom {}))

(defn component-a []
  [:p "hello"]

(swap! serializable-components assoc `component-a component-a)

emccue 2021-06-02T22:36:01.063100Z

maybe making a macro of the last 2 forms

az 2021-06-02T22:37:06.063800Z

Thank you @emccue really appreciate the help