Fork me on GitHub
#reagent
<
2017-07-28
>
pesterhazy09:07:26

@mrchance that's a common problem

pesterhazy09:07:40

it means that you have multiple versions of React in your project

pesterhazy09:07:59

this could be for a variety of reasons

pesterhazy09:07:18

are you using a lib packaged on cljsjs?

pesterhazy09:07:16

these sometimes inadvertently bundle a version of react

mrchance09:07:58

Hi, no, I am reasonably sure that's not the reason. npm ls react shows only one version, and I am not using any cljsjs dependencies

mrchance09:07:08

Same for react-dom

pesterhazy09:07:50

I'll bet you EUR 10 that's the problem

mrchance09:07:56

If I don't use the tabs, but other react bootstrap components I also don't get the error

mrchance09:07:14

Haha, you're on 😄

mrchance09:07:37

How can I make sure?

pesterhazy09:07:06

are you using webpack?

mrchance09:07:29

No, it's an electron app. Only package.json and npm install

mrchance09:07:56

"dependencies": {
       "react": "^15.2.1",
       "react-bootstrap": "^0.31.0",
       "react-codemirror2": "0.0.9",
       "react-dom": "^15.2.1"
     }

pesterhazy09:07:14

that's an awfully old version of react

pesterhazy09:07:19

try updating to 15.4.2

mrchance09:07:25

It's the one reagent uses, so...

pesterhazy09:07:49

well reagent comes with a dependcy on react

pesterhazy09:07:51

did you exclude that?

pesterhazy09:07:13

try lein deps :tree

mrchance09:07:31

oh nuuuh 😄

mrchance09:07:03

[reagent "0.6.1"]
   [cljsjs/react-dom-server "15.4.0-0"]
   [cljsjs/react-dom "15.4.0-0"]
     [cljsjs/react "15.4.0-0"]
You might be right 🙂

pesterhazy09:07:12

try adding

:exclusions [cljsjs/react cljsjs/react-dom cljsjs/react-dom-server]
to your project.clj as a top level key

pesterhazy09:07:28

you'll also need to add surrogate namespaces

mrchance09:07:45

surrogate namespaces...?

mrchance09:07:31

I don't mind upgrading the npm react version too if that fixes it..

pesterhazy09:07:45

this is not about different versions

pesterhazy09:07:08

it's about two instances of react coexisting in the same js runtime

pesterhazy09:07:56

basically you need these empty .cljs files so that the cljs compiler won't complain that the nss are missing

mrchance09:07:42

ah, ok... Maybe it's a better idea to just use the cljsjs versions of react in the rest of the code then? Or does that not work because codemirror will bring their own?

pesterhazy09:07:03

that's right, it probably won't work

mrchance09:07:38

Ok, I'll try that later, thanks for the help. I'll probably need your paypal, just in case 😉

pesterhazy09:07:38

you may also need to do something like window.React = require("react"); window.ReactDOM = require("react-dom");

pesterhazy10:07:01

... before reagent get loaded, so that reagent can find the npm provided version of react

mrchance10:07:29

uh oh. All very straightforward, isn't it 😄

mrchance10:07:42

Ok, can probably squeeze that in the electron init code

pesterhazy10:07:30

yeah it's a bit of a song and dance

pesterhazy10:07:46

isn't there a cljs electron template that does this for you?

mrchance11:07:31

There is, but it didn't anticipate me needing npm deps : )