This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-21
Channels
- # announcements (14)
- # aws (8)
- # babashka (3)
- # babashka-sci-dev (41)
- # beginners (78)
- # calva (15)
- # cider (9)
- # clj-commons (10)
- # clj-kondo (5)
- # cljs-dev (8)
- # clojure (47)
- # clojure-bay-area (3)
- # clojure-europe (13)
- # clojure-nl (2)
- # clojure-norway (15)
- # clojure-uk (13)
- # clojured (2)
- # clojurescript (20)
- # conjure (29)
- # cursive (4)
- # emacs (19)
- # events (3)
- # funcool (13)
- # hyperfiddle (16)
- # jobs (2)
- # lsp (4)
- # malli (13)
- # meander (1)
- # missionary (2)
- # nrepl (7)
- # off-topic (68)
- # other-languages (82)
- # polylith (1)
- # reagent (28)
- # reitit (12)
- # releases (3)
- # remote-jobs (5)
- # ring (27)
- # sci (6)
- # shadow-cljs (9)
- # spacemacs (2)
- # sql (10)
- # tools-deps (10)
- # vim (10)
I have created a reagent
component in the following way.
(ns giggin.components.giggs
(:require [giggin.state :as state]))
(defn gigs
[]
[:main
[:div.gigs (map gig (vals @state/gigs))]])
(defn gig [{:keys [id img title price desc]}]
[:div.gig {:key id}
[:img.gig__artwork {:src img :alt title}]
[:div.gig__body
[:div.gig__title
[:div.btn.btn--primary.float--right.tooltip {:data-tooltip "Add to order"}
[:i.icon.icon--plus]] title]
[:p.gig__price price]
[:p.gig__desc desc]]])
Here state
is a reagent/atom
. Everything rendering correctly. But got the following warning.
[:app] Compiling ...
[:app] Build completed. (163 files, 2 compiled, 1 warnings, 0.24s)
------ WARNING #1 - :undeclared-var --------------------------------------------
File: /home/sakib/Workspace/school/clojure/jacekschae-reagent/learn-reagent-course-files/giggin/src/giggin/components/giggs.cljs:7:20
--------------------------------------------------------------------------------
4 | (defn gigs
5 | []
6 | [:main
7 | [:div.gigs (map gig (vals @state/gigs))]])
--------------------------^-----------------------------------------------------
Use of undeclared Var giggin.components.giggs/gig
--------------------------------------------------------------------------------
8 |
9 | (defn gig [{:keys [id img title price desc]}]
10 | [:div.gig {:key id}
11 | [:img.gig__artwork {:src img :alt title}]
that is because you define gig
after gigs
. need to swap the order of the function to make that warning go away
Figwheel Troubles UPDATE: I learned that you need to keep the tab open to do CLJS… That was my problem I’m having trouble following the tutorial here https://figwheel.org/docs/vim.html they say to:
$ lein repl
user=> (require 'figwheel.main.api)
user=> (figwheel.main.api/start {:mode :serve} "dev")
user=> ;; the above two worked fine
user=> ;; the next line will fail with "No such namespace: figwheel.main.api"
user=> (figwheel.main.api/cljs-repl "dev")
I assume it has to do with what happens when the dev environment is started with my code - all i’d really like to do is connect vim to the cljs repl which requires something like
(figwheel.main.api/cljs-repl "dev")
Does this strike anyone as a problem they’re familiar with?Ah, thanks to @U031CHTGX1T for pointing out that the browser tab needs to be open for this sort of stuff 😅
I literally forget this every other time, so when I get a notice from shadow like "no js runtime" with no browser open I Surprise Pikachu, until I :face_palm::skin-tone-4:
huh? This SO post suggest cljs has an abs
function but... it doesn't. Is this a super recent addition? Not sure what my clojursctipt version is, since I don't think my shadow-cljs config has a direct dependency.
oops https://stackoverflow.com/questions/21753243/absolute-value-of-a-number-in-clojure
> As of Clojure 1.11, it is simply (abs -1)
in both Clojure and Clojurescript.
The commentator is rushing a bit.
According to the docstring of abs
that's in the CLJS repo, it will be available in 1.11.10
which is not released yet.
aww 😞 ok makes sense
Initially I was extra confused because the answer is dated 2014, but it's been edited.