I am trying to get the reagentdemo running in my own project but I’m having problems requiring the clojure namespace reagentdemo/syntax.clj from the clojurescript file reagentdemo/intro.cljs. Can anyone advise me on what’s needed in my lein project.clj The error I get when I “lein cljsbuild once” is: Caused by: clojure.lang.ExceptionInfo: No such namespace: reagentdemo.syntax, could not locate reagentdemo/syntax.cljs, reagentdemo/syntax.cljc, or JavaScript source providing "reagentdemo.syntax" in
Do you want to use a macro from reagentdemo.syntax
?
Yes
And how do you :require
it?
Reagentdemo namespaces aren't included in the package. If you need something from there, you just need to copy the parts to your own project.
I’m requiring it using: (ns reagentdemo.intro (:require [reagent.core :as r] [reagent.dom :as rdom] [reagentdemo.syntax :as s] [reagentdemo.common :as common :refer [demo-component]] ;;[simpleexample.core :as simple] ;; [todomvc.core :as todo] ))
That form is incorrect.
Note how the error that you get complains that it cannot find a cljs, a cljc, or a js file - it never complains about a clj file. Because it doesn't even try to look for it.
You have to use :require-macros
for this. For more details, this is a good read: https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html
Cljs version of the reagentdemo.syntax already does :require-macros
to itself (to the clj version), so no need to use :require-macros
"the modern way" on the post
Hmm, then maybe what you said initially is taking place here. But I'm still confused given that OP wrote about trying to include reagentdemo/syntax.clj
in reagentdemo/intro.cljs
. Which makes it sound like they have the latter but not the former for some reson.
Or maybe "requiring the clojure namespace reagentdemo/syntax.clj from the clojurescript file reagentdemo/intro.cljs" means something else.
:require-macros resolved my problem above. Thx.
If I have a nested-component can I walk inside every component and add a key (example :test-id) on a map of every stateful component?
after r/as-element applied on a component should be impossible to do this?
React elements are immutable, yes.
thanks!