1

When I try to render any Rum's component right in the REPL it fails with the following error message. What am I doing wrong? Is any workaround exists?

:dependencies [[org.clojure/clojure       "1.9.0"]
               [org.clojure/clojurescript "1.10.238"]
               [rum                       "0.11.2"]]
...

=> (rum/defc label [text]
      [:div {:class "label"} text])

=> (label "foo")

 #object[TypeError TypeError: Cannot convert a Symbol value to a string]
   Function.cljs.core.str.cljs$core$IFn$_invoke$arity$1 (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:2944:22)
   cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9994:53)
   cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
   cljs.core/pr-sequential-writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9857:16)
   cljs.core/print-prefix-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10121:4)
   cljs.core/print-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10135:8)
   cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9939:12)
   cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)

Creating a project from the scratch get the same error:

bash-3.2$ lein new figwheel hello-world -- --rum

bash-3.2$ cd hello-world/
bash-3.2$ lein figwheel
...
ClojureScript 1.10.238

dev:cljs.user=> (require '[rum.core :as rum])

dev:cljs.user=> (rum/defc label [text]
           #_=>   [:div {:class "label"} text])
#'cljs.user/label
dev:cljs.user=> (label "foo")
#object[TypeError TypeError: Cannot convert a Symbol value to a string]
   Function.cljs.core.str.cljs$core$IFn$_invoke$arity$1 (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:2944:22)
   cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9994:53)
   cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
   cljs.core/pr-sequential-writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9857:16)
   cljs.core/print-prefix-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10121:4)
   cljs.core/print-map (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10135:8)
   cljs.core/pr-writer-impl (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:9939:12)
   cljs$core$pr_writer (jar:file:/Users/asotnikov/.m2/repository/org/clojure/clojurescript/1.10.238/clojurescript-1.10.238.jar!/cljs/core.cljs:10003:6)
4

1 回答 1

2

这是 clojurescript 的一个已知错误。您可以将其用作临时修复:

(when (exists? js/Symbol)
  (extend-protocol IPrintWithWriter
    js/Symbol
    (-pr-writer [sym writer _]
      (-write writer (str "\"" (.toString sym) "\"")))))
于 2018-07-25T07:05:06.977 回答