Skip to content
This repository has been archived by the owner on Jun 4, 2022. It is now read-only.

Compatibility with reagent #64

Closed
pesterhazy opened this issue Jan 7, 2017 · 5 comments
Closed

Compatibility with reagent #64

pesterhazy opened this issue Jan 7, 2017 · 5 comments

Comments

@pesterhazy
Copy link

I'm trying to play with reagent from lumo.

Initial problems:

Now I can require the ns:

lumo -c x/reagent-0.6.0:$HOME/.m2/repository/cljsjs/react/15.2.1-0/react-15.2.1-0.jar:$HOME/.m2/repository/cljsjs/react-dom-server/15.2.1-0/react-dom-server-15.2.1-0.jar:$HOME/.m2/repository/cljsjs/react-dom/15.2.1-0/react-dom-15.2.1-0.jar
Lumo 1.0.0
ClojureScript 1.9.293
 Docs: (doc function-name-here)
 Exit: Control+D or :cljs/quit or exit

cljs.user=> (require '[reagent.core :as r])
nil
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 527 reagent/ratom.cljs
WARNING: Use of undeclared Var reagent/debug at line 527 reagent/ratom.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 527 reagent/ratom.cljs
WARNING: Use of undeclared Var reagent/debug at line 527 reagent/ratom.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 527 reagent/ratom.cljs
WARNING: Use of undeclared Var reagent/debug at line 527 reagent/ratom.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 123 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 123 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 123 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 123 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 123 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 123 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 295 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 295 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 295 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 295 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 295 reagent/impl/component.cljs
WARNING: Use of undeclared Var reagent/debug at line 295 reagent/impl/component.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 349 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 349 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 349 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 349 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 349 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 349 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 352 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 352 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 352 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 352 reagent/impl/template.cljs
WARNING: No such namespace: reagent, could not locate reagent.cljs, reagent.cljc, or Closure namespace "" at line 352 reagent/impl/template.cljs
WARNING: Use of undeclared Var reagent/debug at line 352 reagent/impl/template.cljs
cljs.user=> (r/create-element "div" #js {:className "foo"} "Hi")
#object[TypeError TypeError: Cannot convert a Symbol value to a string]

However, as you can see, calling create-element (or as-element) fails with a TypeError. Unfortunately without stacktraces, it's hard to figure where the error might be...

@anmonteiro
Copy link
Owner

I think this is not related to Lumo, but is instead an upstream issue in the ClojureScript compiler.

See CLJS-1628 for more context.

Doesn't it work if you don't print the result of create-element? e.g. storing it in a def.

@pesterhazy
Copy link
Author

It does indeed!

@anmonteiro
Copy link
Owner

Awesome. The problem is just with printing, or rather, with println. I think if you use js/console.log it'll print out the Symbol object.

The warnings do seem weird, though. Do you know what's happening there?

@pesterhazy
Copy link
Author

pesterhazy commented Jan 7, 2017

You're right, everything works fine if I apply the technique proposed in http://dev.clojure.org/jira/browse/CLJS-1628 by running this manually:

(extend-protocol IPrintWithWriter 
  js/Symbol 
  (-pr-writer [obj writer opts] 
    (write-all writer "#object[Symbol \"" (.toString obj) "\"]")))

@pesterhazy
Copy link
Author

pesterhazy commented Jan 7, 2017

As for the warnings, they originate in a few lines in debug.clj like this one: https://github.com/reagent-project/reagent/blob/master/src/reagent/debug.clj#L7 so this seems more of a reagent issues to me.

Closing this now as the issues lie elsewehre

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants