rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
Stephen 2021-03-30T16:26:19.007300Z

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?

Stephen 2021-03-30T16:27:18.007600Z

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"]}}
 }

Stephen 2021-03-30T16:59:14.008700Z

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?!)

Stephen 2021-03-30T18:00:32.010900Z

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 🙂

Stephen 2021-03-30T18:10:57.012600Z

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

Stephen 2021-03-30T21:26:51.013400Z

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

Azzurite 2021-03-30T23:51:51.015Z

just here to say that I also get this behavior on 0.12.4, but not on 0.12.3

Azzurite 2021-03-31T17:27:23.015800Z

thanks man, you're great 🙂