This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-28
Channels
- # announcements (2)
- # babashka (36)
- # beginners (29)
- # bristol-clojurians (2)
- # calva (3)
- # cider (102)
- # circleci (7)
- # clj-kondo (5)
- # cljs-dev (7)
- # clojure (117)
- # clojure-europe (23)
- # clojure-korea (1)
- # clojure-nl (1)
- # clojure-spec (15)
- # clojure-uk (47)
- # clojurescript (43)
- # code-reviews (1)
- # community-development (1)
- # conjure (32)
- # cursive (1)
- # datalog (15)
- # datomic (14)
- # emacs (18)
- # fulcro (9)
- # helix (23)
- # jackdaw (1)
- # jobs-discuss (10)
- # meander (8)
- # membrane (57)
- # off-topic (4)
- # portal (2)
- # re-frame (22)
- # reagent (1)
- # reitit (9)
- # reveal (3)
- # rewrite-clj (14)
- # shadow-cljs (22)
- # spacemacs (27)
- # sql (34)
- # testing (6)
- # tools-deps (40)
- # vim (5)
- # vrac (15)
- # xtdb (2)
I am having a situation where my initial page load does work when I use save a page once in shadow-cljs and it rerenders, but not on initial load
I have (fn [] ...)
in the right places
What is usually the cause of this? How to fix?
I've encountered this some time ago. As far as I recall, it was a timing issue. I.e. I was expecting something to be ready by the moment the rendering is started, but it was not.
Yes that’s the case here too
I have something like this:
(defn container [user-info organization-paths]
(let [path (re-frame/subscribe [:permission-panel/active-organization-path])
organization (re-frame/subscribe [:permission-panel/active-organization])]
(fn []
[:div.ml-6
[permission-panel @path user-info @organization]])))```
I expect permission-panel to rerender when there’s a new @organization
And I create a Reagent state from these contents that I update:
(defn permission-panel [path user-info organization]
(let [state (r/atom (permission-state user-info organization))]
(fn []
[history-block @state])))
With sub like this:
(re-frame/reg-sub
:permission-panel/active-organization
(fn [{:permission-panel/keys [active-organization-path] :as db}]
(get-in db [:organisatie/organizations active-organization-path])))
On initial page load the active-organization
is nil
But it is fetched and then it should reload
Which it does not
Why do you wrap (permission-state ...)
in an atom in the first place? Just use it directly, and there won't be the need for the :key
metadata.
permission-state creates the initial state that is used for updating and stuff
It needs to be r/atom because other components use the state to update checkboxes and stuff and @state to rerender themselves
It’s basically component local state
Same problem if I put it in app-db, but I think this is bit nicer since it’s local state
Thanks for the help!
I found the solution!
I added a ^{:key}
Based on the thing that changed later
(defn container [user-info organization-paths]
(let [path (re-frame/subscribe [:permission-panel/active-organization-path])
organization (re-frame/subscribe [:permission-panel/active-organization])]
(fn []
[:div.ml-6
^{:key (:some-value @organization)}
[permission-panel @path user-info @organization]])))
Then the rerender workd