Fork me on GitHub
#reagent
<
2018-11-13
>
athomasoriginal00:11:42

Is there a way to check the version of react reagent is running? In React you can just do React.version. Is there something like this for reagent?

jsa-aerial15:11:35

Just use JS interop: js/React.version

athomasoriginal00:11:23

I’m not sure this would verify what I was trying to prove to myself. If I have a webpack bundle with React in it, not the one installed when you install Reagent, it becomes the global React instance. So This would not tell me which one is which.

jsa-aerial01:11:43

I don't know either. But it is exactly what you gave in 'In React you can just do React.version'.

lilactown00:11:07

do you care about the version of React, or Reagent?

lilactown00:11:21

Reagent will use whatever version of React you have installed

lilactown00:11:39

if you're using figwheel I think it automatically installs a certain version, but you can override it

athomasoriginal00:11:33

I am looking for the version of React that Reagent is currently using. The issue is I am experimenting with my build and want to make sure Reagent is using the version I expect it to

lilactown00:11:10

so you want to know which version of React you have installed. can you not do React.version in your console?

athomasoriginal00:11:03

Yes, but at the moment, I am testing in a node environment so I was hoping for something like reagent.react-version

lilactown00:11:45

again, Reagent will use whatever version of React is installed. it simply references the global namespace

lilactown00:11:00

it has no real notion of what version of react it uses

lilactown00:11:52

in a namespace, you could do:

(ns my.thingy
  (:require ["react" :as react]))

(js/console.log react/version)
and see what it outputs

lilactown00:11:14

er, well, are you using figwheel or shadow-cljs?

lilactown00:11:09

I think that should work either way. if not, remove the quotes around the first react in that require

athomasoriginal00:11:23

I am using figwheel. Right now I have a version of React installed in my node_modules and I have set my npm-deps false but I want to make sure Reagent is not using the version of React from node_modules

athomasoriginal00:11:07

The reason for this is because I am setting up Jest for Reagent tests (experimenting). So I have a webpack bundle which includes react, react-dom, create-react-class and react-test-renderer because react-test-renderer needs these 3 deps.

lilactown00:11:02

I think that requiring react into a namespace and printing the version should do what you want

athomasoriginal01:11:32

Thanks, that helped. For future reference for those interested:

; reagent version of react
(:require ["react" :as react]))
(js/console.log (.. react-reagent -version)

; reagent version of react
(js/console.log (.. js/reagent -impl -template -global$module$react))

; node_modules react
(js/console.log (.. js/demo -my-component-name -global$module$react -version))
All work, the second 2 are ugly and nothing I would do in production, but I was able to verify. Thanks again!