This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-21
Channels
- # announcements (8)
- # beginners (22)
- # calva (42)
- # cider (2)
- # clj-kondo (1)
- # cljdoc (3)
- # clojure (63)
- # clojure-chicago (1)
- # clojure-uk (29)
- # clojurescript (16)
- # clojureverse-ops (2)
- # core-matrix (6)
- # cursive (1)
- # datomic (23)
- # emacs (1)
- # heroku (2)
- # luminus (1)
- # off-topic (47)
- # pathom (1)
- # planck (3)
- # re-frame (4)
- # reitit (1)
- # rewrite-clj (5)
- # shadow-cljs (47)
I have 6 re-frame apps which share some common code. I'm looking for a nice way to define app specific constants which the common code references. I could put an atom in the common lib, have each app update the atom and common code could deref for the current value (perhaps there's a set!/var variant on that approach). I could have all the apps define the common.globals ns themselves and the common code could reference that ns. I can't see how goog-define can help and :preloads is for dev time only.
Having global config atom is fine, been doing this in multiple apps as well.
Am I missing a better approach?
Having written that I think the common lib atom is probably the most sensible.
I'm using the re-frame template lein new re-frame frontend +10x +cider +routes +handler
and the init
function (exported) doesn't seem to be running at all. as a result app-db
is empty. how do i have it run when clojurescript starts?
bah. i wasn't calling init in index.html. solved, thanks!
Anyone else getting this when working with re-frame-10x? Uncaught Invariant Violation: Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
When this appears, re-frame-10x
won't be able to load. sometimes, after refreshing, it goes away
I'm turning a button into a spinner based on a flag, and the button's onclick dispatches something to change that flag. could that be it?
hi how can i run a js code when a react element loaded, i tried like thisb ut no luck ->
(defn main
[]
[:div#products.product-grid.dragarea
(for [x (range 22)] [pcard {:key x}])
(.emitter js/window "some")
]
)
First: for is not meant for side effects, it's lazy and returns a sequence of values. Use doseq instead. Second: this code will be called on every update, unless you really want that you have need to use lifecycle methods such as component-did-mount so that the code runs only once, when component is "loaded"
thank you very much I solved the problem with your guidance. and yes i wanted to run this script on every update
Just to super clear on this. Using render in react for side effects is a bad idea even if you want it to happen on every render. As react moves to concurrent mode, this becomes and even worse idea. If your react wrapper supports hooks, look into use effects. If not look at lifecycle methods or your libraries recommended way to run side effects.