This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-16
Channels
- # aleph (1)
- # aws (2)
- # bangalore-clj (2)
- # beginners (33)
- # cider (3)
- # cljs-dev (4)
- # cljs-experience (6)
- # cljsjs (1)
- # cljsrn (8)
- # clojure (84)
- # clojure-sanfrancisco (1)
- # clojure-spec (6)
- # clojure-uk (5)
- # clojurescript (42)
- # defnpodcast (3)
- # docs (3)
- # emacs (13)
- # events (1)
- # fulcro (2)
- # hoplon (19)
- # liberator (2)
- # off-topic (5)
- # onyx (7)
- # parinfer (1)
- # pedestal (1)
- # re-frame (13)
- # ring-swagger (13)
- # spacemacs (19)
- # yada (2)
I've used cljsjs libraries before but I've recently started to try [cljsjs/react-transition-group "2.2.0-0"] and at runtime get "Uncaught ReferenceError: cljsjs is not defined". Anyone know what would cause that?
(defn line-wrapper
[children]
(js/React.createElement rct/CSSTransitionGroup
#js {:transition-name "asdf"}
(clj->js children)))
I am using leiningen to attempt to provide an edn-file as a string using :closure-defines
, tried
:closure-defines {
"gallery.core.COLOR_EDN" #= (eval (slurp ( "resources/public/gallery-color-data-test.edn")))
}
and it compiled fine, but (require '[gallery.core]) gallery.core/COLOR_END
from the repl and I get`“”`. Any suggestions?The goal is to have this edn config file slurped in at compile time, and available in cljs as and edn string
@tomjkidd it is better to use clojure.edn/read-string
to obtain the EDN and not call eval. E.g., (edn/read-string (slurp "resources/public/gallery-color-data-test.edn"))
. Then you have EDN. I don’t think you need to turn it into a string, but if you do, you can call str
on the last result:
(-> "resources/public/gallery-color-data-test.edn"
slurp
edn/read-string
str)
@tomjkidd I personally prefer to ignore complexity of closure-defines and simply use macros to do any compile-time EDN preparation and then emit it into cljs code as data, e.g. https://github.com/binaryage/cljs-devtools/blob/b42ad914da02cd71d9765d32f54007cb9e2ca68f/src/lib/devtools/prefs.clj#L33
Thanks @U08E3BBST, using something along the lines of what you shared worked like a charm!
Nice! 🙂
Thanks guys, I'm away from the computer right now, but I'll try it out and see if I can get it working.
is there any situation when js->clj
cannot convert a js object?
I have a case where an js object goes in and a js object comes out
@richiardiandrea yes there are many cases, especially in node
. some objects appear as objects but are in fact something native that just looks like a object
uhm...
this object comes with as part of an http request
I’d suggest just using js interop and not worrying about it too much. or write a http->clj
helper fn to do it 😉
ok yeah because it seems js->clj
in ineffective in this case
weirdly typeof(x)
returns object
goog.object makes this stuff much nicer to deal with I think
yeah converting is pretty much always ineffective. especially if you only use a few properties.
yeah ok, good to know that's a lot folks
(def ^{:private true} reader (transit/reader :json))
(def ^{:private true} writer (transit/writer :json))
(t/deftest test-transit
(let [p {1.5 1}
serialized (transit/write writer p)
p' (transit/read reader serialized)]
(t/is (= p p'))))
FAIL in (test-transit) (:)
expected: (= p p')
actual: (not (= {1.5 1} {1 1}))
is this a bug in transit-cljs?wow - I Have never seen this and I use transit extensively
it surfaced while testing some stuff with test.check
hmm I guess it’s not… I can’t reproduce this on transit-cljs master
wait I’m doing something wrong… it doesn’t run my test
now I can reproduce it..
is this expected behaviour or should I submit an issue with a PR including my test?
in project.clj
, how can I specify to figwheel multiple ring-handlers and associate one with a specific cljsbuild config?
:figwheel {:css-dirs ["resources/public/css"]
:ring-handler myapp.handler/dev-handler-1}
:figwheel {:css-dirs [“resources/public/css”]
:ring-handler myapp.handler/dev-handler-2}
I read we can accomplish this with profiles
but I can’t find out how? https://github.com/weavejester/lein-ring/issues/47
Apparently I’m not the only one with this issue: https://github.com/cognitect/transit-cljs/issues/31
@mroerni fwiw I was able to reproduce your transit-cljs issue and added a test that exposes the bug.
I can’t even locate the code in transit-cljs that handles decimals
I have to go, taking a stab at this later
Found my answer.
So i'm new to clojurescript and i'm trying to use the animated library https://github.com/animatedjs/animated which is normally packaged with React Native but instead i'm using it in a browser setting. I have my project.clj settings in the compiler like this:
:npm-deps {:animated "0.2.0"}
:install-deps true
And I can see that the node_modules dir is present as well as a package.json. Now the specific problem is how to correctly (:require) the code. Here is how one has to import it in react if using it in the browser.
import * as Animated from 'animated/lib/targets/react-dom';
What would be the equivalent for cljs?@dfcarpenter (:require ["animated/lib/targets/react-dom" :as animated])
should work
@thheller Thanks, but I now get an error
java.lang.AssertionError: Assert failed: cljs.analyzer/foreign-dep? expected symbol got "animated/lib/targets/react-dom" (symbol? dep)