reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
2021-01-19T13:14:43.032900Z

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?

2021-01-19T13:17:02.033300Z

Yes

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.

2021-01-19T13:56:01.035Z

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: https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html

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.

2021-01-19T16:20:08.037500Z

:require-macros resolved my problem above. Thx.

2021-01-19T20:54:16.038700Z

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?

2021-01-19T20:54:59.039600Z

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.

👍 1
2021-01-19T21:30:54.040600Z

thanks!