This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-28
Channels
- # admin-announcements (2)
- # alda (5)
- # arachne (4)
- # beginners (49)
- # boot (92)
- # capetown (3)
- # cider (9)
- # cljs-dev (6)
- # cljs-edn (1)
- # cljsjs (29)
- # cljsrn (4)
- # clojure (65)
- # clojure-android (1)
- # clojure-berlin (2)
- # clojure-chicago (2)
- # clojure-gamedev (2)
- # clojure-greece (11)
- # clojure-india (1)
- # clojure-japan (1)
- # clojure-new-zealand (2)
- # clojure-quebec (2)
- # clojure-russia (49)
- # clojure-spec (73)
- # clojure-uk (38)
- # clojurescript (118)
- # clojutre (4)
- # community-development (17)
- # cursive (3)
- # data-science (1)
- # datascript (1)
- # datomic (17)
- # emacs (6)
- # euroclojure (2)
- # events (2)
- # immutant (30)
- # keechma (11)
- # leiningen (4)
- # luminus (2)
- # off-topic (19)
- # om (14)
- # onyx (28)
- # planck (9)
- # re-frame (11)
- # reagent (35)
- # ring-swagger (4)
- # schema (4)
- # slack-help (6)
- # spacemacs (2)
- # specter (11)
- # testing (4)
- # untangled (88)
- # utah-clojurians (2)
- # vim (2)
- # yada (9)
when passing multiple ratoms to a component, do you define it as (defn some-component [props children this] )
and pass everying inside the props map? or (defn comp [arg1 arg2 arg3 arg4...])
is the first one the only correct way of defining component which needs more than one ratom argument?
and when I try to pass in as (defn comp [arg1 arg2 arg3...])
, even though the corresponding on-update
function is called when arg3 changed, I still can't see the updated value
However, If I pass in a prop map, I could do (reagent/props component) to get the updated props
Though this feels unnatural to me, I don't understand why is my on-update
function called but no update can be seen
When you say "you can't see the updated value", what do you mean? If you add logging to on-update, what do you see? What about if you add logging to your render function?
Or do you just mean that once the component is rendered, it doesn't look like it updated?
One common mistake with reagent is that you don't use reagent's atoms, but instead clojurescript's normal atoms
@blance: Have you read: https://github.com/Day8/re-frame/wiki/Using-Stateful-JS-Components
@tomerweller: nice!!
@roberto: Really odd that you get that message. Just to state the obvious, you are doing a (:require [reagent.ratom])
, right?
@mikethompson: this is the code:
(ns buttons.ui.subscriptions
(:require [buttons.ui.edb :as edb]
[buttons.ui.entities :as entities])
(:require-macros [reagent.ratom :refer [reaction]]))
(defn links
[app-db]
(reaction
(entities/get-links @app-db)))
(def subscriptions {:links links})
@roberto this looks sane to me, what is your cljs version? It seems that macro loading changed https://github.com/clojure/clojurescript/commit/783001a6786f8dca4a13fdeadc995716903b07f9
for what its worth, I’m not getting the warning anymore. It was probably a figwheel issue because it stopped once I killed figwheel, ran lein clean
and started again
Welcome, @deactivateduser539139!
Fetching data for a component: best done in :component-will-mount
? Or has another best practice arisen?
@mikethompson: I've read that and that's how I build my component. However, the example only has 1 argument passed in, and it seems passing multiple arguments is not as trivial as I thought.
@pesterhazy: Thanks. Apologies for later response. Slack has not been working properly for me.
@petrus: I don't believe in using :component-will-mount
(for loading data). My take: https://github.com/Day8/re-frame/wiki/Subscribing-To-A-Database
@petrus: oops, I've just realised this is the reagent channel, not the re-frame one. So my re-frame solution given above may be too specific. But I'll leave it there for what it is worth.
@blance: what part of multiple arguments is hard? (it shouldn't be hard) I'm guessing here, but did you see the link to: https://www.martinklepsch.org/posts/props-children-and-component-lifecycle-in-reagent.html
@mikethompson: Thanks! that solves my problem.