This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-17
Channels
- # announcements (12)
- # babashka (27)
- # beginners (65)
- # biff (8)
- # calva (22)
- # clj-kondo (1)
- # clj-otel (5)
- # clojure (65)
- # clojure-europe (127)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-portugal (2)
- # clojure-uk (2)
- # clojurescript (18)
- # cursive (5)
- # data-science (3)
- # datahike (14)
- # datascript (3)
- # datomic (7)
- # deps-new (11)
- # emacs (31)
- # exercism (1)
- # fulcro (1)
- # honeysql (3)
- # hyperfiddle (38)
- # introduce-yourself (4)
- # leiningen (2)
- # malli (20)
- # meander (2)
- # missionary (3)
- # off-topic (4)
- # pathom (3)
- # practicalli (2)
- # reagent (5)
- # releases (1)
- # sci (1)
- # shadow-cljs (9)
- # xtdb (8)
I updated reagent to 1.2.0 last night with react 18.2.0. How are you guys handling reloading? When I update a component in another namespace that is NOT part of my requires in the namespace that createRoot calls, the namespace requiring it does not update. It will when calling unmount on root. but this causes a flicker. Can test this with something like this:
;; in parent-ns, this is required from layout's ns
(defn parent-comp []
[:div ...
[child-ns/other-ns]])
;; in child-ns, required from parent's NS, but NOT layout's ns
(defn other-ns []
[:div "change me"])
Reload code in core.cljs
(defonce *root (atom nil))
(defn ^:dev/after-load mount-components []
(rf/clear-subscription-cache!)
;; Flickers, but works.
(let [_ (when @*root (.unmount @*root))
root (reset! *root (rdc/create-root (.getElementById js/document "app")))]
(rdc/render root [layout/page]))
;; When requiring a component from another namespace and updating said component, does not update, UNLESS namespace is included in the layout namespace
(let [root (or @*root (reset! *root (rdc/create-root (.getElementById js/document "app"))))]
(rdc/render root [layout/page]))
;; Reverts to old react 17, works fine without flickering.
(rdom/render [layout/page] (.getElementById js/document "app")))
Yes, that's my last example in my last code snippet. Reagent 1.2.0 has been updated for react 18 as far as the changelog suggest and most my app works fine with it.