This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-03-30
Channels
- # babashka (18)
- # beginners (90)
- # calva (33)
- # clara (6)
- # cljfx (11)
- # cljs-dev (22)
- # cljsrn (9)
- # clojure (71)
- # clojure-australia (2)
- # clojure-czech (15)
- # clojure-europe (27)
- # clojure-germany (9)
- # clojure-nl (4)
- # clojure-serbia (3)
- # clojure-uk (10)
- # clojurescript (17)
- # conjure (12)
- # data-oriented-programming (2)
- # deps-new (6)
- # fulcro (29)
- # graphql (10)
- # hugsql (6)
- # jobs (1)
- # lsp (59)
- # malli (8)
- # off-topic (76)
- # pathom (15)
- # polylith (130)
- # re-frame (9)
- # reagent (15)
- # releases (4)
- # rewrite-clj (6)
- # ring (6)
- # rum (9)
- # shadow-cljs (116)
- # specter (5)
- # testing (7)
- # tools-deps (24)
- # vim (6)
- # xtdb (17)
I am having the following common.cljc
:
(ns projectname.common
(:require [rum.core :include-macros true :as rum]))
(rum/defc my-comp [a f b]
[:div [:h1 a] [:h2 f] [:span b]])
which I inculde like this in my core.cljs
:
(ns projectname.core
(:require [rum.core :as rum]
[projectname.common :refer [my-comp]]))
(rum/hydrate (my-comp "3" "test" 3) (js/document.getElementById "app"))
But I always get this wired error (shadow-cljs):
2 | (:require [rum.core :include-macros true :as rum]))
3 |
4 | (rum/defc my-comp [a f b]
5 | [:div [:h1 a] [:h2 f] [:span b]])
---------------------^----------------------------------------------------------
Use of undeclared Var projectname.common/a
--------------------------------------------------------------------------------
Can someone please point me to my error?This is my deps.edn
:
{:paths ["src/clj" "resources", "src/cljc"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}
metosin/reitit {:mvn/version "0.5.2"}
http-kit/http-kit {:mvn/version "2.3.0"}
rum/rum {:mvn/version "0.12.4" :exclusions [cljsjs/react cljsjs/react-dom]}
}
:aliases {:run {:main-opts ["-m" "projectname.core"]}
:shadow-cljs
{:extra-deps {thheller/shadow-cljs {:mvn/version "2.11.26"}}
:extra-paths ["src/cljs/"]
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}
}
Funnily enough, the .clj
code can import the cljc
file without problems. It must be something with ClojureScript and/or shadow-cljs (maybe some special config for .cljc
files?!)
It must have something to do with taking the wrong defc implementation when importing the cljc file from cljs. I guess some Readermacro ( #?(:cljs ... :clj ....) ) But I can not figure out how to make that work Please help 🙂
Even tried this:
(ns projectname.common
(:require #?(:cljs [rum.core :refer-macros [defc]]
:clj [rum.core :refer [defc]])))
(defc my-comp [a f b]
[:div "this comp is from cljc" [:h1 a] [:h2 f] [:span b]])
Still, I get:
1 | (ns projectname.common
2 | (:require #?(:cljs [rum.core :refer-macros [defc]]
3 | :clj [rum.core :refer [defc]])))
4 |
5 | (defc my-comp [a f b]
6 | [:div "this comp is from cljc" [:h1 a] [:h2 f] [:span b]])
----------------------------------------------^---------------------------------
Use of undeclared Var projectname.common/a
--------------------------------------------------------------------------------
I figured that the first render seems to work. It may not even be because of the .cljc
file.
Please see https://clojureverse.org/t/how-to-start-with-clj-shadow-cljs-rum/7403/5
Thanks for pointing into this, most likely a regression, I'll take a look