Fork me on GitHub
#reagent
<
2021-01-19
>
Humanist196513:01:43

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

p-himik13:01:24

Do you want to use a macro from reagentdemo.syntax?

p-himik13:01:45

And how do you :require it?

juhoteperi13:01:35

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.

Humanist196513:01:01

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] ))

p-himik14:01:06

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

juhoteperi14:01:34

Cljs version of the reagentdemo.syntax already does :require-macros to itself (to the clj version), so no need to use :require-macros

juhoteperi14:01:39

"the modern way" on the post

p-himik14:01:07

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.

p-himik14:01:50

Or maybe "requiring the clojure namespace reagentdemo/syntax.clj from the clojurescript file reagentdemo/intro.cljs" means something else.

Humanist196516:01:08

:require-macros resolved my problem above. Thx.

Ian Fernandez20:01:16

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?

Ian Fernandez20:01:59

after r/as-element applied on a component should be impossible to do this?

p-himik21:01:10

React elements are immutable, yes.

👍 3