Fork me on GitHub
#helix
<
2020-07-08
>
jaime20:07:43

Hi, anyone have an example app using reitit frontend router and helix?

jaime20:07:13

Not an app, but I'm using this one right now as start.

(defnc root []
  (let [[match set-match] (hooks/use-state nil)
        view (get-in match [:data :view])]
    (rfe/start!
      router
      (fn [m]
        (when (not= m match)
          (set-match m)))
      {:use-fragment true})
    ($ :div {:class ""}
      ($ :a {:href (rfe/href :limeray.web.routes/home)} "back")
      ($ :a {:href (rfe/href :limeray.web.routes.goals/add)} "New Goal")
      (when view
        ($ view match)))))
Routes
(def routes
  [["/"
    {:name :limeray.web.routes/home
     :view home-view}]
   ["/goals"
    ["/"
     {:name :limeray.web.routes/goals
      :view list-view}]
    ["/add"
     {:name :limeray.web.routes.goals/add
      :view add-goal-view}]]])