This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-25
Channels
- # announcements (2)
- # babashka (22)
- # beginners (31)
- # calva (4)
- # cider (26)
- # clj-kondo (10)
- # clojure (32)
- # clojure-europe (1)
- # clojure-italy (3)
- # clojure-nl (3)
- # clojure-spec (16)
- # clojure-switzerland (5)
- # clojure-uk (25)
- # clojurescript (108)
- # clojutre (15)
- # code-reviews (3)
- # data-science (1)
- # datomic (92)
- # emacs (1)
- # fulcro (8)
- # graalvm (8)
- # jackdaw (8)
- # jobs (1)
- # jobs-discuss (1)
- # leiningen (6)
- # off-topic (56)
- # pathom (6)
- # pedestal (5)
- # re-frame (11)
- # remote-jobs (1)
- # shadow-cljs (4)
- # spacemacs (2)
- # sql (41)
- # tools-deps (7)
- # xtdb (25)
Just had a doozy of an advanced compilation bug. We're using Leaflet which uses a global variable "L" (e.g. window.L). The advanced compilation process produces short variables so L gets clobbered (turned into cljs.core/conj in fact).
Since our code doesn't reference window.L directly our infer externs didn't kick in to protect it.
I'm waiting for a "doh!" moment. Seems rather unsafe to randomly clobber global (window) vars.
Ah, I'm using deps.edn instead of the lein cljsbuild plug-in. Cljsbuild sets :output-wrapper true for advanced builds
Are there some reagent experts here? I am trying to find a reagent/react event to hook into. I want to see if any of the arguments that have been passed have changed. I tried a lot: :reagent-component-will-receive-props :component-will-receive-props :get-snapshot-before-update :should-component-update . It seems that ONLY the render function seems to see the new argv.
Have you tried :component-did-update (fn [this old-argv old-state snapshot])
then use reagent.core/props
on this
to get new props http://reagent-project.github.io/docs/master/reagent.core.html#var-props
@hoertlehner what are you trying to do specifically?
I have a couple of components, that need to request data with :api-route and :query-params.
[reagent "0.8.2-SNAPSHOT" :exclusions [cljsjs/react cljsjs/react-dom]] ; reagent has older react references than material-ui
To clarify, you don't see any of the printlns in component-will-receive-new-props ?
so let’s delete that, get-snapshot-before-update, reagent-component-will-receive-props, etc.
fetch-comp component-did-mount {:month 10} repl.cljc:251:17 fetch-comp component-will-update {:month 10} repl.cljc:251:17 fetch-comp component-did-update: :bad
fetch-update error! repl.cljc:251:17 fetch-comp component-will-update {:month 10} repl.cljc:251:17 fetch-comp component-did-update: :bad
it’s not clear to me what you’re actually doing, how the error you’re talking about might relate, etc.
does anyone know why we might see a substantial difference between lein-cljsbuild/figwheel incremental compiles vs. shadow-cljs?
with lein-figwheel, compilation takes ~20s for some changes. with shadow-cljs, it takes <1s for the same changes
yes, that’s my current hypothesis now after reading your blog on hot reload again 😄
Hi, what am I doing wrong here? The error is shadow-cljs - [reload failed] Failed to load my/app.cljs: [object Object] is not ISeqable
(ns
(:require [reagent.core :as r]))
(def todos (r/atom (list {:id 1 :title "Task 1"}
{:id 2 :title "Task 2"})))
(defn todo-list [items]
[:div
(for [todo todos]
[:div (:title todo)])])
(defn app []
[todo-list todos])
(r/render [app]
(js/document.getElementById "app"))
Probably try (for [todo @todos]
instead of the for
you have now.
The value of todos
is not a sequence, but an atom, and you cannot iterate over an atom
@todos
could also be written (deref todos)
-- @todos
is just a short-hand syntax for (deref todos)
Warning: I know nothing about reagent and its conventions -- I do know something about ClojureScript
@andy.fingerhut Yes, you’re right! defining the todos
as (removing the atom) worked!
(def todos (list {:id 1 :title "Task 1"}
{:id 2 :title "Task 2"}))
FYI, given that there is a literal syntax for vectors, and vectors and lists are often fairly interchangable in Clojure (at least in many contexts), you could also write that as
(def todos [{:id 1 :title "Task 1"}
{:id 2 :title "Task 2"}])
if you wanted to.make sense. do we have to consider if we are iterating or inserting in first/last element? Or it wont matter that much perf wise?
Yes, hence why I said 'in many contexts', not 'in all contexts'. The primary difference between lists and vectors in Clojure is that lists are fast for inserting new elements at the beginning, and vectors at the end. And that vectors have fast lookup by index, whereas lists are linear time for that. For traversing their elements as a sequence, their performance is so close it well as may be identical.
The .-which
in this line seems to be a js object interop? https://github.com/reagent-project/reagent/blob/master/examples/todomvc/src/todomvc/core.cljs#L39
Where can I find the api for these?
Can’t find it in the cheatsheet https://cljs.info/cheatsheet/
@jaime.sangcap are you asking about JS interop in general or .-which
in particular?
@thheller I think for now I’m curious what is .-which
and where it is coming from. Because in javascript, there is no method like that in KeyboardEvent
?
But you can also tell me more about JS interop in general, I would appreciate that and would help me alot get started
thread macros works with cljc?
(-> app #?(:clj http-driver-clj :cljs http-driver-cljs))