Fix router reload issue

pull/645/head
Tienson Qin 2020-03-08 17:22:42 +08:00
parent d1b511eafe
commit 2f0734ebbd
2 changed files with 15 additions and 10 deletions

View File

@ -4,23 +4,27 @@
[frontend.page :as page]
[frontend.routes :as routes]
[reitit.frontend :as rf]
[reitit.frontend.easy :as rfe]
[reitit.coercion :as rc]
[reitit.coercion.spec :as rss]))
[reitit.frontend.easy :as rfe]))
(defn set-router!
[]
(rfe/start!
(rf/router routes/routes {})
handler/set-route-match!
;; set to false to enable HistoryAPI
{:use-fragment false}))
(defn start []
(rum/mount (page/current-page)
(.getElementById js/document "root")))
(rum/mount
(page/current-page)
(.getElementById js/document "root"))
(set-router!))
(defn ^:export init []
(prn "init!")
;; init is called ONCE when the page loads
;; this is called in the index.html and must be exported
;; so it is available even in :advanced release builds
(rfe/start!
(rf/router routes/routes {:data {:coercion rss/coercion}})
handler/set-route-match!
;; set to false to enable HistoryAPI
{:use-fragment false})
;; (handler/get-me)

View File

@ -6,6 +6,7 @@
[]
(let [state (rum/react state/state)
route-match (:route-match state)]
(prn "route: " route-match)
(if route-match
(when-let [view (:view (:data route-match))]
(view route-match)))))