Fork me on GitHub

I have created a reagent component in the following way.

(ns giggin.components.giggs
  (:require [giggin.state :as state]))

(defn gigs
   [: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.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}]


This belongs more in #reagent But the error is using gig before defining it.

thanks3 1

CLJS is different from JS in this regard.

👍 1

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 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 😅

👍 1

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:

❤️ 1
Pepijn de Vos13:04:13

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.


Which post? :)

Pepijn de Vos13:04:57

> 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.

Pepijn de Vos13:04:12

aww 😞 ok makes sense

Pepijn de Vos13:04:45

Initially I was extra confused because the answer is dated 2014, but it's been edited.


is there a duratom equivalent in cljs?


I mean literally, not something like datahike, konserve


I also realize it would be MUCH simpler because of concurrency model


i think what most people do is use a regular atom with a watch that persists wherever you want, and on startup loads the data from wherever


if you're just persisting to local storage it's quite easy


thanks that's a simpler solution which should fit my usecase