This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-17
Channels
- # 100-days-of-code (5)
- # announcements (13)
- # beginners (98)
- # boot (19)
- # cider (10)
- # cljdoc (32)
- # clojure (142)
- # clojure-dev (37)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-spec (30)
- # clojure-uk (18)
- # clojurescript (28)
- # cursive (8)
- # datomic (25)
- # duct (18)
- # editors (5)
- # emacs (39)
- # events (4)
- # figwheel (7)
- # figwheel-main (5)
- # fulcro (38)
- # graphql (19)
- # jobs-discuss (1)
- # jobs-rus (7)
- # keechma (1)
- # lumo (47)
- # off-topic (28)
- # om-next (3)
- # parinfer (3)
- # re-frame (18)
- # reagent (37)
- # reitit (8)
- # shadow-cljs (101)
- # specter (7)
- # tools-deps (8)
- # vim (1)
How possible detect multiple keys at Reagent? e.g. at :on-key-down
when I want to detect SHIFT+ENTER, when (.-key e) give me back input .. I see just SHIFT event, possible to see SHIFT+ENTER response?
also is there any documentation of how to target a specific dom element from outside of the ref scope?
looking at react docs, there seems to be a whole set of style props but the reagent way is unclear
it’s pretty much the same, but you provide a map for :style
and you use :class
instead of className
you don’t want to programmatically change the style using the ref, you just want to re-render with the new style/class like you would in react
yeah but I want to change the class of specific children depending on interaction and state of other components
so something like [:span {:style {:color (if (= status :red) "red" "black")}} "text"]
you don’t need refs here. refs are only handy if you need to access the underlying dom element or you have a library that exposes methods
declaratively writing code to specify your styling based on state is kind of the raison d’etre of react
ok its basically a parent with a number of children generated to represent part of a json map
so the react way of doing that is you just regenerate the whole tree based on the new state. so you’ll have a variable somewhere, either in a component-local closure or in a state atom, that records which thing is selected. then you just style each component based on that data.
i think you are approaching this the way you’d do it in jquery, where when something gets selected you’d go select the right nodes and then change them imperatively
well, and to more directly answer your question, I do not know how to change styling given a ref. you could probably use the DOM API to do it directly, but react is probably going to clobber it in unpredictable ways in later renders
ok, I guess I was hoping there was a reagent way to do this rather than querying the map again
i’m not sure what you mean. you should just write the render method as a pure function of state. keep the selected elements in state, then when you render each child, write conditional logic to set the styling. react will preform vdom reconciliation and do the mutations to the real dom for you.