helix

https://github.com/Lokeh/helix
fabrao 2020-04-18T00:35:35.222Z

hello, how do I use child stuffs with helix??

Aron 2020-04-18T00:36:27.222200Z

what is that

fabrao 2020-04-18T00:36:30.222400Z

(defnc Btn [{:keys [child]}] (d/div child))

Aron 2020-04-18T00:37:04.222700Z

but that's ambiguous, child could be any value

fabrao 2020-04-18T00:37:36.223400Z

($ Btn "Hello")

Aron 2020-04-18T00:38:00.223700Z

I had this question a couple hours ago 😉

fabrao 2020-04-18T00:38:14.224Z

really? 🙂

Aron 2020-04-18T00:38:58.224200Z

can you see history?

lilactown 2020-04-18T00:39:37.225200Z

@fabrao children are available via the children props just like in React

Aron 2020-04-18T00:39:53.225900Z

well, that was an obvious answer too, but I thought they know

lilactown 2020-04-18T00:40:49.226600Z

(defnc Btn
  [{:keys [children]}]
  (d/div children))

($ Btn "Hello")

fabrao 2020-04-18T00:47:26.227200Z

@lilactown That was kid problem :-)

fabrao 2020-04-18T00:48:00.227400Z

thanks a lot

fabrao 2020-04-18T01:10:54.228400Z

How to deal with props? Like this?

(defnc Btn [{:keys [props children]}]
       (d/div props children))
?

fabrao 2020-04-18T01:11:19.228900Z

($ Btn {:class "fool"} "AHAH")

lilactown 2020-04-18T01:12:55.229200Z

hmm. I don't have docs for that

lilactown 2020-04-18T01:13:15.229500Z

you need to use Clojure destructuring

lilactown 2020-04-18T01:14:23.230Z

the whole map is props and a key on it is children

lilactown 2020-04-18T01:14:46.230400Z

so the correct syntax is [{:keys [children] :as props}]

lilactown 2020-04-18T01:20:34.230600Z

see here about passing in props dynamically: https://github.com/Lokeh/helix/blob/master/docs/creating-elements.md#dynamic-props

fabrao 2020-04-18T02:12:48.231400Z

[{:keys [children] :as props}] is that correct? -> Error "Objects are not valid as a React child"

fabrao 2020-04-18T03:04:05.231800Z

Can I do this?

(defnc Btn [{:keys [children] :as props}]
       (d/div {:& props} children))

fabrao 2020-04-18T03:05:29.232100Z

as I tried, it worked

fabrao 2020-04-18T03:12:24.232400Z

or

(defnc Btn [{:keys [children] :as props}]
       (d/div {:& (dissoc props :children)} children))

2020-04-18T14:02:56.233100Z

is helix compatible with workspaces ?

lilactown 2020-04-18T15:11:39.233500Z

unless something has changed drastically since I last used workspaces, yes

lilactown 2020-04-18T15:12:50.234500Z

I believe you just create an element in the card:

(ws/defcard hello-card
  (ct.react/react-card
    (helix.dom/div "hello world")))

lilactown 2020-04-18T15:13:00.234800Z

you can use $ as well. should be very straight forward

lilactown 2020-04-18T15:13:06.235Z

@geraldodev are you having issues?

2020-04-18T15:40:27.239800Z

@lilactown No, I'm going to take a stab with cljs + helix. I'm watching you since the Abramov/Reagent discussion on twitter. Today I saw this library and I'm going to try clojure on the client again.

lilactown 2020-04-18T16:30:54.240100Z

great, I hope you enjoy it!

dominicm 2020-04-18T18:00:24.240200Z

Curious, what discussion?

fabrao 2020-04-18T23:14:16.241500Z

So, why is this not work if I change the string "Fernando !!!!!!--"

(defnc imprimir [{:keys [children]}]
       (d/div children))

(defnc App [{:keys [children]}]
       ($ imprimir children))

(defn ^:export start
  []
  (rdom/render ($ App "Fernando !!!!!!--")  (js/document.getElementById "app")))
but

fabrao 2020-04-18T23:15:12.241900Z

(defnc imprimir [{:keys [children]}]
       (d/div children))

(defnc App []
       ($ imprimir "Fernando !!!!!!"))

(defn ^:export start
  []
  (rdom/render ($ App )  (js/document.getElementById "app")))
this work