helix

https://github.com/Lokeh/helix
Aron 2020-04-26T09:15:39.461500Z

Is there a way to create unnamed components? something like

(def components-by-type {"typestring-passed-by-js" #($ GeneralInputComponent {:geninputprop1 "config-str-for-typestr-and-geninput" :geninputprop2 "another-config-str-for-typestr-and-geninput" :geninputpropn "andanother-config-str-for-typestr-and-geninput" & %})}   
But the map components-by-type has dozens of entries. I found that generally speaking I have less generalinputcomponents and typestrings and configs for typestrings than how many names I have to figure out for reactcomponents, so I would like to avoid doing this work 🙂

Aron 2020-04-26T09:21:38.463Z

#(GenInp (clj->js (merge {:cfg "cfgstr"} (js->clj % )))) seems to work X)

Aron 2020-04-26T09:22:06.463300Z

I am going to pretend it's fine : D

dominicm 2020-04-26T09:57:13.463700Z

I think I saw a fnc macro

Aron 2020-04-26T10:17:22.463900Z

maybe internally?

dominicm 2020-04-26T10:39:15.464100Z

yeah, it's private.

Aron 2020-04-26T10:45:58.464600Z

and the above pattern breaks because I should only convert the top layer

Aron 2020-04-26T10:48:33.466700Z

It's a conundrum because I don't know how to come up with descriptive names for all these components, eventually it should be configured automatically so it will be even harder. It feels bit like The Kingdom of Nouns

Aron 2020-04-26T11:29:08.467400Z

Would be nice to see the first example here in helix: https://reactjs.org/docs/hooks-state.html#hooks-and-function-components

2020-04-26T15:06:03.468700Z

https://github.com/geraldodev/react-form-hook-test/blob/master/src/main/app/core.cljs#L60 helix + malli + react-form-hook example

lilactown 2020-04-26T16:29:16.469900Z

I’ll think about how to make fnc friendly enough to make public

Aron 2020-04-26T16:48:02.471Z

@lilactown is there no way currently to achieve this? I am unsure even - at the moment, having thought about relatively shortly - how to achieve with just react api, so that I can use helix components.

lilactown 2020-04-26T17:50:53.471600Z

There’s not a public api for it in helix

lilactown 2020-04-26T17:52:01.472700Z

You can always use a fn: (fn [props] ,,,)

lilactown 2020-04-26T17:52:43.473800Z

props will be a JS obj so you’ll need to use interop or convert it to a CLJS map-alike

lilactown 2020-04-26T17:53:11.474300Z

That’s all defnc really does

Aron 2020-04-26T18:09:17.474800Z

@lilactown I think in the above example, I did use a function, no?

Aron 2020-04-26T18:09:59.475600Z

and I am saying that because of the clj->js conversion, I am getting erros that Uncaught Error: [object Object] is not ISeqable

Aron 2020-04-26T18:10:48.476300Z

sadly these erros break everything, and there are zero good stacktraces, I don't even know which level it happens...

lilactown 2020-04-26T18:13:23.477300Z

I’ve pasted an example I think the last time you asked this. Not at a computer rn so I can’t type it out

Aron 2020-04-26T18:15:00.478800Z

@lilactown sorry, I didn't want to trouble you : ), I will go back, but I don't remember me asking this specific question, and the last time I asked similar you specifically told me to use a named function, which is the matter of my current question, I would like to avoid having to come up with names for these functions.

lilactown 2020-04-26T20:48:39.480700Z

you can do this for now:

(fn [-props]
  (let [props (cljs-bean.core/bean -props)]
   ,,,))

Aron 2020-04-26T22:22:39.481900Z

thanks @lilactown, bean seems very useful. Btw, the issue was I think that I wanted to use (map) over a hashmap, because that works in clojure, but not with a js object, but I passed this hashmap through props...

Aron 2020-04-26T22:25:26.482600Z

in js I used .entries() to map over key/value pairs

Aron 2020-04-26T22:30:42.483500Z

(map #(let [[_ [key value]] %]                                                                                                                                
                   ($ MenuItem {:value key :key key}                                                                                                                     
                     ($ "em" value)))                                                                                                                                    
             (.entries js/Object items)))))))
Maybe there is a more clojure-i way 😄

Aron 2020-04-26T22:37:12.484Z

actually, I am just doing everything wrong. I wish I had a hammock