This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-30
Channels
- # admin-announcements (10)
- # beginners (17)
- # boot (14)
- # braveandtrue (4)
- # cider (6)
- # cljsrn (38)
- # clojure (232)
- # clojure-austin (1)
- # clojure-belgium (2)
- # clojure-dev (20)
- # clojure-greece (20)
- # clojure-japan (3)
- # clojure-poland (39)
- # clojure-russia (76)
- # clojure-sanfrancisco (6)
- # clojure-uk (4)
- # clojurescript (90)
- # cursive (2)
- # data-science (10)
- # datomic (18)
- # garden (16)
- # hoplon (244)
- # immutant (3)
- # jobs (6)
- # jobs-discuss (2)
- # juxt (1)
- # off-topic (3)
- # om (50)
- # onyx (23)
- # re-frame (5)
- # reagent (36)
- # remote-jobs (11)
- # slack-help (6)
- # spacemacs (2)
- # untangled (46)
Hi guys! I have a little problem with the rendering cycle (or so I guess) with re-frame. I have the following component:
(defn app-root []
(let [logged-in? (subscribe [:logged-in?])]
(if @logged-in?
(fn []
(println "Logged in:")
(println @logged-in?)
[logged-in-view])
(fn []
(println "Logged in:")
(println @logged-in?)
[login-view]))))
When logged-in?
changes through re-frame, the println triggers but reagent doesn't use the logged-inview. It keeps showing the login-view instead@dvcrn use this ... (not sure I have the parens right)
(defn app-root []
(let [logged-in? (subscribe [:logged-in?])]
(fn []
(if @logged-in?
[logged-in-view]
[login-view]))))
In your version, the first time app-root
was called, it returned a render function which was then forever used as the renderer. In effect, in your version the if
was never evaluated again after the first time.
Whereas in my Form2
component the returned render function will be rerun (producing potentially different hiccup) each time @logged-in?
changes
Be sure to read this: https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components
hey guys, I’m looking for a cljs dev (game development experience a plus) for a reagent based ux project. We're a startup based in China and so initially it’ll be remote/project based work. Please ping me if you’re interested (<mailto:[email protected]|[email protected]>) with your resume and previous creations.
Hello, I would like to use an external React component (https://github.com/gre/multi-slider) within reagent code. How am I supposed to do that?
@pbaille: https://github.com/reagent-project/reagent/blob/master/src/reagent/core.cljs#L49
how to add a key in map (map (fn [v] [test-comp v]) variables)
. I tried to add :key to first div in test-comp function, and have a warning about unique key for element in a seq
I have also noticed that if you use into and for it doesn’t complain about missing a key
(into [:ul] (for [item items] [:li item]))
@adamkowalski: using into
will circumvent the need for keys, because the ul will be recreated on each re-render. So it avoids the need for keys, but also won't take advantage of react's ability to not re-render list items that havent changed. For small lists, I like using into, but you will have performance issues if you try that for "large" lists (whatever that means lol)
oh, that is good to know. I should probably go back and replace all my intos then haha