Fork me on GitHub
#reagent
<
2017-06-03
>
reefersleep17:06:09

I'm trying to add react-with-addons, so I can use ReactCSSTransitionGroup as mentioned in this example: https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/ReactCSSTransitionGroup However, when I load my app, I get util.cljs:11Uncaught Error: js/React is missing in my browser console. My project.cljhas the following in the :dependencies vector:

[reagent "0.6.0-rc" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
                 [cljsjs/react-with-addons "15.4.2-2"]
                 [cljsjs/react-dom-server "15.1.0-0"]
What am I doing wrong?

pesterhazy17:06:54

it could be stale build files (try a different browser, lein clean)

pesterhazy17:06:04

or it could be load ordering

pesterhazy17:06:46

to debug, open the page in chrome and see if window.React is set in the devtools

reefersleep19:06:50

@pesterhazy the above was witnessed in Chrome. On your advice, I tried Firefox, this shows the "ClojureScript has not been compiled!" page, but without the util.cljs:11Uncaught Error: js/React is missing error in the console

reefersleep19:06:57

I suspect it's the same problem, though

reefersleep19:06:13

I've lein cleaned multiple times

reefersleep19:06:32

window.React returns undefined in the chrome console

reefersleep19:06:44

Guess I'll try and look for additional stale assets

gadfly36119:06:43

If you are seeing a message like clojurescript has not been compiled then you likely need to run something like lein figwheel to compile cljs again after the clean

gadfly36119:06:22

Also, i wouldnt recommend using different versions of react-with-addons and react-dom-server

reefersleep19:06:51

Every time I change something, I do lein clean, lein figwheel

reefersleep19:06:58

the browser connets to my figwheel repl

reefersleep19:06:30

I'll try using the same addons and dom-server versions

pesterhazy19:06:24

@reefersleep are you require cljsjs/react-with-addons somewhere in your project?

pesterhazy19:06:54

I mean (:require [cljsjs.react])

pesterhazy19:06:14

I guess so, if you're using reagent?

reefersleep19:06:35

No, not directly

pesterhazy19:06:52

I think there's a caching/tooling problem here, not necessarily a project.clj problem

reefersleep19:06:55

... leme try something

pesterhazy19:06:23

I'd try to get it to work in firefox (which has a fresh browser cache)

reefersleep19:06:24

Currently, my project.clj is:

[reagent "0.6.0-rc" :exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]]
                 [cljsjs/react-with-addons "15.5.4-0"]
                 [cljsjs/react-dom-server "15.5.4-0" :exclusions [cljsjs/react]]
                 [cljsjs/react-dom "15.5.4-0" :exclusions [cljsjs/react]]

reefersleep19:06:33

With lein clean and lein figwheel, and mv'ing my project/public/js. Wonder if there are other assets somewhere.

gadfly36119:06:48

@reefersleep please see issue i linked

reefersleep19:06:55

And using Firefox makes no difference.

gadfly36119:06:56

try version 15.4.1-0 or below

pesterhazy19:06:15

do you see "ClojureScript has not been compiled" ?

reefersleep19:06:36

yes, in both browsers @pesterhazy

pesterhazy19:06:59

well then your problem is actually not React, but your figwheel setup

pesterhazy19:06:19

you could try starting a new lein new figwheel and check the diff

gadfly36119:06:01

its possible its an early runtime error (because of the react issue) and so see the default 'clojurescript has not been compiled' page

reefersleep19:06:48

It worked just fine before I added the react-with-addons dependency, though, @pesterhazy - I've been working on this project on and off for half a year 🙂

pesterhazy19:06:12

I'd try if that's really the only change you made

reefersleep19:06:23

But my experience tells me that you might as well be right, sometimes things get messed up. 🙂

pesterhazy19:06:23

if you can reliably break it by changing that dep

reefersleep19:06:42

oh wait, there's a reason it displays the error

reefersleep19:06:50

sorry I didn't say this earlier

reefersleep19:06:12

According to the example for using transition groups, I've added the following lines to my core.cljs:

(def css-transition-group
  (r/adapt-react-class js/React.addons.CSSTransitionGroup))

reefersleep19:06:29

And the error actually occurs at the js/React call

reefersleep19:06:40

since it is undefined

pesterhazy19:06:58

ah so that's it

reefersleep19:06:03

But the problem is really the same, react is not being loaded as a dependency. It's as if the react-with-addons dependency does not contain react itself.

pesterhazy19:06:06

try deferring loading this

pesterhazy19:06:32

to defer, use [:> js/React.addons.CSSTransitionGroup] instead

pesterhazy19:06:20

are you 100% sure that window.React is not visible in the firefox console after loading the page?

reefersleep19:06:09

yup, it's undefined

reefersleep19:06:20

where do I put [:> js/React.addons.CSSTransitionGroup]?

reefersleep19:06:54

I tried commenting out the call to `js/React, by the way, but of course react is called elsewhere, so I get the exact same error

reefersleep19:06:37

Also, by the way, this issue mentions making empty namespaces for cljsjs.react and cljsjs.react.dom, which I have also done: https://github.com/reagent-project/reagent/issues/275

juhoteperi11:06:47

reefersleep: I'm not sure what you are trying, but you should NOT create these empty namespaces if you use cljsjs packages. This is only for those providing React in some other way.

reefersleep20:06:13

Thank you both for your help. I'm going to keep at it. Wonder if I could do something to clean my .m2

reefersleep20:06:18

Also, I'll follow your advice and try to reproduce the problem with a minimal example

reefersleep20:06:15

I tried lein new reagent-frontend foo and adding the same dependencies, and foo displays the default page without a hitch.

reefersleep20:06:49

So I guess it's either some cache problem with my main project or a project.clj problem... or a code problem.

reefersleep20:06:00

Even if I include [cljsjs/react "15.4.1-0"] in my dependencies, react is missing. Weird.

juhoteperi11:06:47

reefersleep: I'm not sure what you are trying, but you should NOT create these empty namespaces if you use cljsjs packages. This is only for those providing React in some other way.