This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-07
Channels
- # announcements (2)
- # asami (2)
- # babashka (15)
- # babashka-sci-dev (31)
- # beginners (130)
- # boot (4)
- # cider (5)
- # circleci (12)
- # clj-kondo (10)
- # cljs-dev (8)
- # clojure (7)
- # clojure-czech (14)
- # clojure-europe (19)
- # clojure-france (5)
- # clojure-uk (2)
- # clojured (23)
- # clojurescript (11)
- # conjure (8)
- # datomic (5)
- # emacs (1)
- # etaoin (8)
- # events (2)
- # fulcro (10)
- # graalvm (18)
- # gratitude (1)
- # holy-lambda (16)
- # honeysql (4)
- # introduce-yourself (1)
- # jobs (2)
- # kaocha (3)
- # london-clojurians (1)
- # lsp (53)
- # off-topic (16)
- # other-languages (2)
- # pathom (4)
- # pedestal (3)
- # podcasts (1)
- # portal (10)
- # re-frame (69)
- # reitit (2)
- # shadow-cljs (11)
- # vim (7)
- # xtdb (29)
Hi I'm calling rfe/start! on the top level unit, before the 1st invocation of rfe/href in order to not getting error message due to it's null value. Aftewards on the main component I call rfe/start! again on a hooks/use-effect context. Do you see any problem in that approach ?
;; Calling before the first use of rfe/href in order to initialize the routing process and not blow up react
;; because "No protocol method Router.match-by-name defined for type null: " that happens when (rfe/href)
;; is called without reitit.frontend.easy being globally initialized
(rfe/start!
(rf/router routes)
(constantly nil)
{:use-fragment true})
(defnc LeftMenu
[{:keys [match]}]
(d/ul
(d/li (d/a {:href (rfe/href ::countries)} "Countries"))
(d/li (d/a {:href (rfe/href ::regions)} "Regions"))))
(defnc RootComponent
[]
(let [[match set-match] (hooks/use-state nil)
view (get-in match [:data :view])]
(hooks/use-effect
:once
(rfe/start!
(rf/router routes)
(fn [m]
(set-match m))
{:use-fragment true}))