Fork me on GitHub

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
 (rf/router routes)
 (constantly nil)
 {:use-fragment true})

(defnc LeftMenu
  [{:keys [match]}]
   (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])]
      (rf/router routes)
      (fn [m]
        (set-match m))
      {:use-fragment true}))