This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-12
Channels
- # announcements (1)
- # babashka (42)
- # beginners (114)
- # bristol-clojurians (2)
- # calva (7)
- # cider (4)
- # clj-kondo (7)
- # cljs-dev (37)
- # cljsrn (13)
- # clojure (114)
- # clojure-austin (3)
- # clojure-europe (5)
- # clojure-nl (10)
- # clojure-spec (77)
- # clojure-sweden (4)
- # clojure-uk (16)
- # clojurescript (52)
- # conjure (155)
- # core-async (18)
- # cursive (23)
- # datomic (20)
- # duct (2)
- # emacs (13)
- # figwheel (3)
- # figwheel-main (9)
- # fulcro (31)
- # gis (8)
- # helix (33)
- # jobs (12)
- # jobs-discuss (66)
- # kaocha (4)
- # lein-figwheel (1)
- # meander (16)
- # off-topic (5)
- # pathom (13)
- # pedestal (6)
- # quil (6)
- # rdf (17)
- # re-frame (32)
- # reagent (34)
- # reitit (30)
- # remote-jobs (1)
- # ring (2)
- # shadow-cljs (149)
- # spacemacs (1)
- # sql (8)
- # tools-deps (90)
- # xtdb (19)
@sansaripour @andre Subbing outside of the renderer is not the rule anymore since subs are cached. The changelog entry: https://github.com/day8/re-frame/blob/master/CHANGELOG.md#090-20161215---the-dolores-release An example in the README: https://github.com/day8/re-frame/blob/master/docs/CodeWalkthrough.md#the-view-functions One exception: https://github.com/day8/re-frame/blob/master/docs/FAQs/UseASubscriptionInAnEventHandler.md
The benefit is simpler code and subscription reuse. If using form-2 components is your personal preference, that's OK. But please don't tell people that "that's the rule".
#object[Error Error: Vector's key for assoc must be a number.]
cljs$core$IAssociative$_assoc$arity$3 (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:5550:14)
cljs.core/-assoc (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:630:17)
Function.cljs$core$IFn$_invoke$arity$3 (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:1972:8)
cljs$core$assoc (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:1965:1)
sval (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:3399:18)
cljs$core$ISeqable$_seq$arity$1 (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:3453:12)
cljs$core$seq (jar:file:/home/user/.m2/repository/org/clojure/clojurescript/1.10.439/clojurescript-1.10.439.jar!/cljs/core.cljs:1210:25)
what could be causing this? I have googled around and can't seem to find any answers
Can you provide more information about what you mean by inspect app stage
What exactly did you do in figwheel?
app:cljs.user=> (require '[re-frame.core :as re-frame])
nil
app:cljs.user=> @re-frame.db/app-db
Your stack trace seems to indicate that you were using assoc
, perhaps on a vector
Puzzling
The error is saying that the index where you are associng must be an int. You can't do in fact:
(assoc [] :hello 3)
It's weird to use assoc for vectors, yet I find myself doing it in some cases when the vector is somewhere nested in a map i.e.:
(assoc-in {:a {:b [1 2 3]}} [:a :b 0] :replacement-value-at-index-0)
@lucio But this stack trace doesn't really say where in my code I'm making such a mistake in my code... it's really hard to find it
@p-himik I just saw your response regarding my re-frame subs question. And just to be clear - because I've been getting different opinions on this from different folks - you're saying that in the below (contrived) example - deref'ing outside the component - is ok?
;; only immutable data gets passed in to the component
(defn my-component [s] [:div s])
;; this function is the "view" that gets rendered and may contain many components
(defn my-panel []
[:<>
[my-component @(rf/subscribe [::subs/my-sub])]]))
Just to give context, I've been deref'ing all of my subs outside of my components (^similar to the example above) in the "panels"/overall-views to keep the components themselves pure, easily-testable, and reusable across projects. It was only recently that someone pointed out to me that deref'ing outside of the component/leaf-nodes may impact performance poorly. And so, before I embark in refactoring a ton of code I'd like certain verification of the aforementioned point.That is a very good point indeed, and I will definitely do that. But, I'd still like to know right off the bat if I'm driving on the wrong side of the road.
@sansaripour this might help you https://github.com/Day8/re-frame/issues/218
a while back reframe introduced some sugar around derefing in the different form-1/2/3 components. i dont particularly like it, but its there
Thanks, this helps 👍