This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-09
Channels
- # beginners (205)
- # boot (6)
- # cider (22)
- # cljs-dev (41)
- # cljsrn (4)
- # clojure (97)
- # clojure-dev (61)
- # clojure-greece (40)
- # clojure-italy (8)
- # clojure-russia (16)
- # clojure-spec (18)
- # clojure-uk (34)
- # clojurescript (14)
- # community-development (1)
- # cursive (45)
- # datomic (39)
- # fulcro (66)
- # jobs (2)
- # lein-figwheel (1)
- # lumo (9)
- # off-topic (8)
- # parinfer (98)
- # portkey (8)
- # re-frame (81)
- # reagent (54)
- # remote-jobs (17)
- # ring (2)
- # shadow-cljs (217)
- # spacemacs (32)
- # sql (24)
- # test-check (6)
- # unrepl (73)
- # yada (12)
Hello all, I´m using soda-ash
and I want to know what is the as={Segment}
in <Sidebar.Pushable as={Segment}>
mean? How to convert to reagent stuff?
from reagent you can use it like
[:> (.-Pushable Sidebar) {:as Segment} "here you put yout children components" ]
@gadfly361 so how do I convert to clojurescript Sidebar.Pushable as=...?
what is the converting for [SidebarPushable {:as <something>}]
, what do I use in <something>
?
there is probably a better way to do this, but think it is actually {:as (aget js/semanticUIReact "Segment")}
Using "Segment" will make the html tag literally be a segment... whereas doing the aget thing will create a div will the proper classes (i.e. "ui segment")
@gadfly361 is any way to pass reagent compoent here?
I would have tried the same as what @fabrao has already tried, so seems like you need to use the react version of the component .. so if as-element and reactify-component dont work, i am at a loss.
@mateusz.probachta, i don't think the :as is a free-form component .. i think it parses it and adds appropriate classes depending on which specific semantic ui component it is .. this is just a specific thing about semantic ui react i think (but been a long time since ive thought about semantic so could be wrong)
@mateusz.probachta i believe as-component and as-element are the same, one is just a legacy name
@fabrao I apologize for not having an elegant answer, but i would try {:as (aget js/semanticUIReact "Segment")}
and see if that works for you
a previous convo found here: https://clojurians-log.clojureverse.org/clojurescript/2017-05-14.html (search for soda-ash)
the same question:
"I am currently using soda-ash ( a reagent adaptation of semantic-ui react). While dealing with sidebar there is 'as' prop that needs a string/function ( a react component). here's what i am doing
[sa/SidebarPushable {:as (r/reactify-component [sa/Segment])} [sa/Sidebar {:as (r/reactify-component [sa/Menu]) :vertical true :inverted true :animation "overlay"} [sa/MenuItem {:name "Strategies"} [sa/Icon {:name "puzzle"}]]]]
"
Side question about
gadfly361 [3:23 AM] @fabrao I apologize for not having an elegant answer, but i would try
{:as (aget js/semanticUIReact "Segment")}` and see if that works for you`
I recently dove into React Native and have read a bunch of existing projects. and keep seeing folks use aget
on ClojureScript objects. I had understood that this was discouraged, since it is fragile in advanced compilation. Has something changed? Or, when is it ok to use? (I've been using oops.core\oget
and ocall
instead. Am I being correct, or just overly cautious?
@deg aget
should only be used on arrays, as simple as that :)
There’s a warning you can add to your builds to detect bad use of aget.
for objects you should us: (.-bar foo)
=> foo bar
or (.. foo -bar -baz)
=> foo.bar.baz
but in clojurescript aget
sould be ok because it is translated to (aget foo "bar" "baz")
=> foo["bar"]["baz"]
I got error messages Warning: Each child in an array or iterator should have a unique "key" prop.
from time to time, but can't figure out where does it come from.
The issue is that I have pretty complicated form with lots of fields, which is generated, so I can't check each of them by hand. I'm looking for a more general solution which ideally would print out the element in question.
@deg @mateusz.probachta Instead of aget
use goog.object
functions for field access.
It’s explained here https://clojurescript.org/news/2017-07-14-checked-array-access
@deg i did not noticed oops lib in your comment. Its rly nice way to deal with js interop (I reading cljs-oops docs now)
how would I convert this to reagent: https://github.com/STRML/react-grid-layout/blob/master/test/examples/1-basic.jsx