Fork me on GitHub

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?


Just use JS interop: js/React.version


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.


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


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


Reagent will use whatever version of React you have installed


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


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


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


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


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


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


in a namespace, you could do:

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

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


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


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


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


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.


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


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!