This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-04
Channels
- # announcements (6)
- # beginners (207)
- # calva (39)
- # cestmeetup (35)
- # chlorine-clover (36)
- # clj-kondo (15)
- # clj-together (1)
- # cljsrn (2)
- # clojure (110)
- # clojure-europe (8)
- # clojure-italy (9)
- # clojure-nl (2)
- # clojure-uk (5)
- # clojurescript (61)
- # conjure (4)
- # cursive (1)
- # datalog (3)
- # datomic (22)
- # emacs (8)
- # events (2)
- # figwheel-main (11)
- # fulcro (23)
- # graalvm (16)
- # graphql (1)
- # helix (4)
- # jobs (5)
- # jobs-discuss (4)
- # malli (3)
- # mid-cities-meetup (13)
- # off-topic (58)
- # pathom (12)
- # re-frame (30)
- # reagent (45)
- # reitit (1)
- # reveal (7)
- # sci (2)
- # shadow-cljs (173)
- # spacemacs (1)
- # sql (1)
- # test-check (5)
- # xtdb (13)
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:
[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}]
(def Redirect (r/adapt-react-class react-router-dom/Redirect)) (def Route (r/adapt-react-class react-router-dom/Route))
or :render #(r/as-element [:> Redirect {:to "/home"}])
if Redirect
is a React component (and not a Reagent component)
fwiw I'm trying the example here: https://github.com/reagent-project/reagent/blob/master/doc/UsingSquareBracketsInsteadOfParens.md#appendix-2 where it is supposed to fail, and it works...
not sure if the docs on teh doc/ folder are supposed to be deprecated or something
I wish someone knowledgeable would tidy up these docs 😞 Maybe in celebration of 1.0? 🙂
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)
yeah I feel some of the docs are just outdated, thing is, when learning, it is hard to determine which thing is wrong
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).
right, I meant, maybe it was correct at some point, otherwise it would not had been written (I want to think) haha
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
maybe once I learn the thing I should try doing something like that 🙂
has anyone seen this error before?
[Figwheel] figwheel-main.edn is valid \(ツ)/
[Figwheel] Compiling build dev to "resources/public/cljs-out/dev-main.js"
internal/modules/cjs/loader.js:1088
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.<anonymous> ([eval]-wrapper:10:26)
at Module._compile (internal/modules/cjs/loader.js:1256:30)
at evalScript (internal/process/execution.js:98:25) {
code: 'MODULE_NOT_FOUND',
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
I found some references about this online but none of them seen to apply to my project
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"]]
and
{: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"
:target-path]}
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 believemm 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
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
yeah probably let me try to change a few things