This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-31
Channels
- # aleph (3)
- # aws (5)
- # beginners (65)
- # boot (17)
- # cljs-dev (112)
- # cljsrn (5)
- # clojure (146)
- # clojure-austin (3)
- # clojure-dusseldorf (3)
- # clojure-italy (18)
- # clojure-norway (13)
- # clojure-russia (84)
- # clojure-serbia (5)
- # clojure-spec (24)
- # clojure-uk (84)
- # clojurescript (204)
- # css (1)
- # cursive (21)
- # data-science (3)
- # datascript (21)
- # datomic (26)
- # emacs (5)
- # euroclojure (1)
- # hoplon (8)
- # jobs (7)
- # jobs-discuss (2)
- # keechma (35)
- # lumo (92)
- # mount (1)
- # nrepl (2)
- # numerical-computing (16)
- # off-topic (10)
- # om (58)
- # re-frame (13)
- # reagent (90)
- # remote-jobs (2)
- # ring-swagger (1)
- # spacemacs (9)
- # specter (6)
- # unrepl (17)
- # untangled (56)
- # yada (2)
@gadfly361 Have you used it already?
I have used it in production and enjoyed it. It does take control of your react version which is annoying, but outside of that it works well :)
I predominantly use flexbox for things like that: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Really depends on your target audience and if you want to support old versions of IE .. if you do, then using a grid layout from a css framework may be more up your alley. Ive found if i avoid using flexbox to stretch things vertically, i dont get bitten by ie too bad...but i also am not trying to explicitly support ie10 and below either for most things i work on.
@gadfly361 what do you mean by "takes control of your react version"?
@pesterhazy As I noticed, cljs-react-material-ui carries its own version of the react, that loads when I require it in ns, for example, in deps I have reagent 0.6.1 with react 15.4.2 and cljs-react-material-ui 0.2.44 (this version have own react 15.5.4), if I exclude cljsjs.react in reagent, react will be loaded throw mui and have 15.5.4 version, simple check with React.version
so the issue is that cljs-react-material-ui has its own dependency on cljsjs.react? Or does it actually include it in the jar?
[INFO] +- cljs-react-material-ui:cljs-react-material-ui:jar:0.2.39:compile
[INFO] | +- (org.clojure:clojure:jar:1.8.0:compile - omitted for conflict with 1.9.0-alpha14)
[INFO] | +- (org.clojure:clojurescript:jar:1.8.40:compile - omitted for conflict with 1.9.518)
[INFO] | +- cljsjs:material-ui:jar:0.17.1-0:compile
[INFO] | \- camel-snake-kebab:camel-snake-kebab:jar:0.4.0:compile
Hi do you know any library or sample project which I can refer to implement reagent to fetch "GraphQL" ? Let me know please.
@pesterhazy im not sure which, i just remember trying to change the react version from whatever cljs-react-material-ui comes with and not having any luck at the time
anyone using reagent and dealing with perf issues for larger transactions (say transacting facts about 50+ entities which do indeed all correspond to a posh pull and subsequent reagent component)?
Just wondering if this is considered outside the wheelhouse of what it is intended for
I’m getting react errors complaining about a missing :key prop when mapping over a number of components. The components in question all have unique keys. Any idea of what’s going on?
at line 108 i map over show-file. in this case it’s just a list of strings pointing to images already pre-loaded
so i will get a lazy sequence back composed of [show-thumbnail2 field form-options c file]
I also have a weird bug where removing files with the callback messes with the rendering. the ratom is properly updated, but the pictures are not
if it rings a bell for anyone i’d be happy to see some pointers 🙂. otherwise i’ll continue to wrestle with it
gunna see if i can strip this down to a smaller example and maybe give some thoughts
https://github.com/emil0r/ez-form is the repo
@emil0r this will remove the error (but i am using gensym to make arbitary keys ... so instead replace that with your own)
(defmulti show-file (fn [field form-options c file]
(cond
(string? file) :image
:else (.-type file))))
(defmethod show-file "image/jpeg" [field form-options c file]
^{:key (gensym)} [show-thumbnail field form-options c file])
(defmethod show-file "image/png" [field form-options c file]
^{:key (gensym)} [show-thumbnail field form-options c file])
(defmethod show-file "image/gif" [field form-options c file]
^{:key (gensym)} [show-thumbnail field form-options c file])
(defmethod show-file :image [field form-options c file]
^{:key (gensym)} [show-thumbnail2 field form-options c file])
(defmethod show-file :default [_ _ c file]
(let [[size suffix] (get-size file)]
^{:key (gensym)}[:div.preview {:key (.-name file)}
[:div.details
[:div.size [:span [:strong size] " " suffix]]
[:div.name [:span (.-name file)]]]
[:div.remove {:on-click (cb-remove-file c file)}
(*t* *locale* ::remove-file)]]))
ha well that's a fortunate side effect, guess react needed to know the key to track the item
if I want to create a react Dimmer (from soda-ash for example) from inside a :on-click event of some div, how would I do it?
@gadfly361 thanks!
metadata isn’t data that drives rendering, in this context it’s used so that react can keep track of which element is which even as contents are updated
(so it can differentiate “this thing moved” from “this thing is completely different now”)
(def some-list (range 10))
;; Get warning: Every element in a seq should have a unique key
(map (fn [i]
[:div i]) some-list)
;; No warning
(map (fn [i]
[:div {:key i} i]) some-list)
;; No warning
(map (fn [i]
^{:key i}
[:div i]) some-list)
either should work, often times it is just a matter of incorrect placement when using the key attribute (i always use metadata ... just habit)
@gadfly361 oh, nice, I didn’t realize putting a :key in the props worked like that
@noisesmith I didn't really either, just had seen it in other's code ... so just tested it out and works
in normal JS React, you have to pass key as a prop, so I just kind of assumed that it worked here too
@gadfly361 👍 good
using devcards now, and sometimes a change in ratom doesn't trigger an update, was thinking maybe somehow related
https://github.com/dimovich/coverton/blob/master/src/devcards/coverton/devcards.cljs
another shot in the dark (likely wont matter), but try wrapping the for
in your component with a doall
instead of wrapping the stuff inside the for with a do
https://github.com/dimovich/coverton/blob/master/src/cljs/coverton/components.cljs#L175-L176
yeah - all do inside for does is let you do things for side effects and throw away the values
@gadfly361 the into ensures that a doall would be redundant
it’s eager with eager types
I think it only works with eager types though 😄
eg. in this case there’s no such thing as a lazy vector, so the into can’t be lazy
Hello everyone ! So I have a bunch of ratoms, which contain boolean values. I'd like to create a new ratom which will contain true
when all of the ratoms are true and false when either is false ? Should I look into reaction
?
@florinbraghis try track
(defonce ratom1
(reagent/atom false))
(defonce ratom2
(reagent/atom false))
(defn all-true? []
(and @ratom1
@ratom2))
(defn page []
(let []
[:div
[:h1
"All true? " (str @(reagent/track all-true?))]
[:div
[:button
{:on-click #(reset! ratom1 (not @ratom1))}
"Toggle ratom1 (" (str @ratom1) ")"]
[:button
{:on-click #(reset! ratom2 (not @ratom2))}
"Toggle ratom2 (" (str @ratom2) ")"]
]]))
Here are some more notes on track: https://reagent-project.github.io/news/news060-alpha.html
👍 @gadfly361 . thank you, will try it !