This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-12
Channels
- # aleph (10)
- # beginners (79)
- # boot (81)
- # chestnut (3)
- # cider (9)
- # cljs-dev (336)
- # cljsrn (17)
- # clojure (121)
- # clojure-boston (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-russia (218)
- # clojure-spec (32)
- # clojure-uk (98)
- # clojurescript (109)
- # cloverage (1)
- # core-async (5)
- # cursive (17)
- # datascript (15)
- # datomic (38)
- # editors (4)
- # emacs (6)
- # graphql (1)
- # hoplon (140)
- # instaparse (1)
- # jobs (2)
- # klipse (1)
- # leiningen (4)
- # lumo (2)
- # mount (103)
- # off-topic (3)
- # om (8)
- # onyx (19)
- # parinfer (32)
- # pedestal (3)
- # precept (32)
- # re-frame (33)
- # reagent (24)
- # remote-jobs (11)
- # rum (1)
- # spacemacs (1)
- # specter (37)
- # unrepl (4)
- # untangled (43)
- # vim (11)
Hi all, I find myself doing lots of (let [index (:index @state/app-state)])
statements in my reagent app. Is there some sort of global alias I can use to define these at the top level? Something like (def index (:index @state/app-state))
? thx!
no but you can use a cursor
I'm new to reagent but I suppose a reaction set up to access that property could also be elegant?
yup, though IMO r/track and r/cursor have sort of superseded using raw reactions
good to know, most tutorials I've seen focus on reactions over cursors, claiming cursors are less useful or more problematic. but i suppose all of this is moot if you are using re-frame
(def !index (r/cursor !app-state [:index]))
then use @!index
to deref
an additional benefit is that components get rerendered more selectively
by the way I use the exclamation mark to mark "dereffables"
@pesterhazy Thx! Looks like what I need. Will have to read up on cursor a bit. Thanks again!
remember, you need to deref (use @
) in the component you want rerendered when the dereffable changes
I'm new to reagent but I suppose a reaction set up to access that property could also be elegant?
Trying to translate some Props from a React component. Not sure what to do with references like "this"
class WebcamCapture extends React.Component {
*setRef = (webcam) => { this.webcam = webcam* ; }
Hi! I am trying to use react-codemirror via
(defonce code-mirror-component (js/require "react-codemirror"))
(defonce code-mirror (reagent/adapt-react-class code-mirror-component))
(defn editor [state]
[code-mirror {:value @state
:on-change #(reset! state %)}])
It works, but it doesn't update when I reset!
state, only on fighweel reload. Any ideas why?@mrchance Is state
a Reagent atom?
In fact I tried this:
[:div
[editor my-state]
[:div @my-state]
[button {:on-click #(swap! my-state str "f")} "Append"]]
the div updates, the editor doesn't...