A minimalistic ClojureScript interface to React.js

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-himik 2021-01-19T13:16:24.033Z

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



p-himik 2021-01-19T13:19:45.033500Z

And how do you :require it?

juhoteperi 2021-01-19T13:31:35.033700Z

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

p-himik 2021-01-19T14:00:06.035200Z

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:

juhoteperi 2021-01-19T14:40:34.035500Z

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

juhoteperi 2021-01-19T14:41:39.035700Z

"the modern way" on the post

p-himik 2021-01-19T14:47:07.035900Z

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-himik 2021-01-19T14:47:50.036100Z

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?

p-himik 2021-01-19T21:19:10.039800Z

React elements are immutable, yes.