A minimalistic ClojureScript interface to React.js
whoops 2020-08-04T00:31:49.101700Z

I think may've confused yourself. You only want to use the compiler if you want to change what Reagent generates (i.e. make it generate functional components by default). If you just want one functional component that's overkill. See the sections "Functional Components" and "Hooks" here:

whoops 2020-08-04T00:37:03.102Z

Also the docs don't mention there is an :f> shortcut now, see:

Hobgoblin 2020-08-04T08:29:48.104700Z

Hello, I'm porting existing TSX code to CLJS and while mostly successful it seems I have a hard time writing this """<Route exact path="/" render={() => <Redirect to="/home" />} />""" in CLJS. I have already tried the following:

Hobgoblin 2020-08-04T08:33:06.106200Z

[Route {:path "/" :render #(r/reactify-component [Redirect {:from "/" :to "/home"}]) :exact true}] [Route {:path "/" :render (fn [_] [:> js/Redirect {:to "/home"}]) :exact true}]]]])) [Route {:path "/" :render (fn [_] (r/reactify-component [#'react-router-dom/Redirect {:to "/home"}])) :exact true}] [Route {:path "/" :render (fn [_] [RootRedirectDerivedFromRedirect {:to "/home"}]) :exact true}] [:> react-router-dom/Route {:path "/" :render #([:> react-router-dom/Redirect {:to "/home"}]) :exact true}] [:> react-router-dom/Route {:path "/" :render (fn [_] [:> react-router-dom/Redirect {:to "/home"}]) :exact true}]

Hobgoblin 2020-08-04T08:33:20.106500Z

at the same time this seems to work just fine

Hobgoblin 2020-08-04T08:33:32.106700Z

[Route {:path "/home" :component (r/reactify-component Home) :exact true}]

Hobgoblin 2020-08-04T08:34:22.107100Z

I have required ["react-router-dom" :as react-router-dom]

Hobgoblin 2020-08-04T08:34:39.107400Z

and defined the following

Hobgoblin 2020-08-04T08:34:40.107600Z

(def Redirect (r/adapt-react-class react-router-dom/Redirect)) (def Route (r/adapt-react-class react-router-dom/Route))

Hobgoblin 2020-08-04T08:34:53.107800Z


arttuka 2020-08-04T09:12:14.108700Z

:render #(r/as-element [Redirect {:to "/home"}])

arttuka 2020-08-04T09:12:43.109300Z

or :render #(r/as-element [:&gt; Redirect {:to "/home"}]) if Redirect is a React component (and not a Reagent component)

EmmanuelOga 2020-08-04T09:37:26.109800Z

fwiw I'm trying the example here: where it is supposed to fail, and it works...

jsn 2020-08-05T09:10:38.132100Z

Well, my guess would be that that specific one at least is not just outdated, it seems just plain wrong (as in: I have doubts Reagent ever behaved that way).

EmmanuelOga 2020-08-05T23:47:15.132700Z

right, I meant, maybe it was correct at some point, otherwise it would not had been written (I want to think) haha

EmmanuelOga 2020-08-05T23:47:48.132900Z

would be awesome to have some sort of build for the docs: if you use a piece of code as an example, should be extracted from a test suite or something

EmmanuelOga 2020-08-05T23:48:04.133100Z

maybe once I learn the thing I should try doing something like that 🙂

jsn 2020-08-05T23:51:17.133300Z


EmmanuelOga 2020-08-04T09:37:59.110100Z

not sure if the docs on teh doc/ folder are supposed to be deprecated or something

EmmanuelOga 2020-08-04T09:38:41.110300Z

I wish someone knowledgeable would tidy up these docs 😞 Maybe in celebration of 1.0? 🙂

jsn 2020-08-04T10:46:12.110500Z

It actually works for me even with reagent 0.10.0

jsn 2020-08-04T10:56:27.110700Z

I'm having trouble coming up with an interpretation of "Appendix 2" that would not be hopelessly incorrect (but then again, I don't know much about Reagent)

Hobgoblin 2020-08-04T13:58:21.111100Z

@arttuka that worked. thx man!


has anyone seen this error before?

[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "resources/public/cljs-out/dev-main.js"
  throw err;

Error: Cannot find module '@cljs-oss/module-deps'
Require stack:
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1085:15)
    at Function.Module._load (internal/modules/cjs/loader.js:928:27)
    at Module.require (internal/modules/cjs/loader.js:1145:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at [eval]:8:13
    at Script.runInThisContext (vm.js:132:18)
    at Object.runInThisContext (vm.js:315:38)
    at Object.&lt;anonymous&gt; ([eval]-wrapper:10:26)
    at Module._compile (internal/modules/cjs/loader.js:1256:30)
    at evalScript (internal/process/execution.js:98:25) {


it seems to fail when it loads react-dom


even if the dependency is there, and it's kind of a trivial project for now

lilactown 2020-08-04T15:56:59.113100Z

I’ve seen this error many times and always forget how it’s fixed


I found some references about this online but none of them seen to apply to my project

lilactown 2020-08-04T15:57:11.114Z

what version of figwheel/cljs are you using?


the deps are just

:dependencies [[org.clojure/clojure "1.10.0"]
                 [org.clojure/clojurescript "1.10.773"]
                 [org.clojure/core.async  "0.4.500"]
                 [cljs-ajax "0.8.0"]
                 [reagent "0.10.0"]]
{:dependencies [[binaryage/devtools "1.0.2"]
                                  [com.bhauman/figwheel-main "0.2.11"]]

                   ;; need to add dev source path here to get user.clj loaded
                   :source-paths ["src" "dev"]
                   ;; need to add the compiled assets to the :clean-targets
                   :clean-targets ^{:protect false} ["resources/public/cljs-out"


the error I eventually get in the browse is just

dom.cljs:16 Uncaught TypeError: Cannot read property 'render' of undefined
    at reagent$dom$render_comp (dom.cljs:16)
    at Function.cljs$core$IFn$_invoke$arity$3 (dom.cljs:41)
    at reagent$dom$render (dom.cljs:27)
    at Function.cljs$core$IFn$_invoke$arity$2 (dom.cljs:36)
    at reagent$dom$render (dom.cljs:27)
but that's simply because react-dom was not imported properly I believe

lilactown 2020-08-04T16:03:15.115800Z

sure if the loader isn’t compiling and running then it’s gonna have problems

lilactown 2020-08-04T16:04:19.116Z

I would try bumping all your deps

lilactown 2020-08-04T16:04:39.116300Z

and clearing your build cache

lilactown 2020-08-04T16:04:45.116600Z

maybe start with that first, actually


mm looks like disablin [binaryage/devtools "1.0.2"] makes it work


would be good to understand why


ah no interesting now the first error is gone but the second is still there


it still doesn't load react-dom properly, even if I cleaned already and hard reloaded, weird

lilactown 2020-08-04T16:10:57.120100Z

are you excluding cljsjs/react-dom ?


no no it's definitively there

[reagent "1.0.0-alpha2"]
   [cljsjs/react-dom-server "16.13.0-0"]
   [cljsjs/react-dom "16.13.0-0"]
   [cljsjs/react "16.13.0-0"]


and I can see the react js file being fetched correctly in the network tab

lilactown 2020-08-04T16:17:57.122600Z

probably worth asking in #figwheel-main

lilactown 2020-08-04T16:18:19.122900Z

doesn’t sound like it’s a reagent problem tbh

lilactown 2020-08-04T16:18:41.123400Z

I would investigate your build config


yeah probably let me try to change a few things