hello, how do I use child
stuffs with helix??
what is that
(defnc Btn [{:keys [child]}] (d/div child))
but that's ambiguous, child could be any value
($ Btn "Hello")
I had this question a couple hours ago 😉
really? 🙂
can you see history?
https://clojurians.slack.com/archives/CRRJBCX7S/p1587143405208100
https://clojurians.slack.com/archives/CRRJBCX7S/p1587143887209700
@fabrao children are available via the children
props just like in React
well, that was an obvious answer too, but I thought they know
(defnc Btn
[{:keys [children]}]
(d/div children))
($ Btn "Hello")
@lilactown That was kid problem :-)
thanks a lot
How to deal with props? Like this?
(defnc Btn [{:keys [props children]}]
(d/div props children))
?($ Btn {:class "fool"} "AHAH")
hmm. I don't have docs for that
you need to use Clojure destructuring
the whole map is props
and a key on it is children
so the correct syntax is [{:keys [children] :as props}]
see here about passing in props dynamically: https://github.com/Lokeh/helix/blob/master/docs/creating-elements.md#dynamic-props
[{:keys [children] :as props}]
is that correct? -> Error "Objects are not valid as a React child"
Can I do this?
(defnc Btn [{:keys [children] :as props}]
(d/div {:& props} children))
as I tried, it worked
or
(defnc Btn [{:keys [children] :as props}]
(d/div {:& (dissoc props :children)} children))
is helix compatible with workspaces ?
unless something has changed drastically since I last used workspaces, yes
I believe you just create an element in the card:
(ws/defcard hello-card
(ct.react/react-card
(helix.dom/div "hello world")))
you can use $
as well. should be very straight forward
@geraldodev are you having issues?
@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.
great, I hope you enjoy it!
Curious, what discussion?
https://twitter.com/dan_abramov/status/1086694676206444544?lang=en
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(defnc imprimir [{:keys [children]}]
(d/div children))
(defnc App []
($ imprimir "Fernando !!!!!!"))
(defn ^:export start
[]
(rdom/render ($ App ) (js/document.getElementById "app")))
this work