Fork me on GitHub
#clojurescript
<
2022-12-22
>
DerTev13:12:08

Any idea, why this doesnt update, when I reset! current-post?

(defn home []
  (cond
    (not (nil? @post-view/current-post)) [post-view/post]
    @pb/logged-in [feed]
    :else [login]))

DerTev13:12:50

The post-view is

(defn post []
  [:div {:id "layout"}
   [:div {:class ["border-top" "border-end" "border-start"] :id "post"}
    [:h1 {:id "title"} (.-name @current-post)]]])
and I reset! current-post with
:on-click #(.info consola (pr-str (reset! post-view/current-post x)))

p-himik13:12:59

How do you use home? Also, (not (nil? ...)) can be replaced with (some? ...).

DerTev14:12:51

In render it directly

DerTev14:12:10

Btw the change between login and home works

DerTev14:12:25

But the post-view doent work

p-himik14:12:44

Can you provide the actual code where home is used?

p-himik14:12:59

And the code where current-post is defined.

DerTev14:12:43

(d/render [home/home] (.getElementById js/document "app"))
and
(def current-post (atom nil))

p-himik14:12:10

Did you use clojurescript.core/atom in there or reagent.core/atom?

p-himik14:12:44

Which one? :)

DerTev14:12:46

That sounds like this is the issue

p-himik14:12:49

They're both core.

DerTev14:12:52

I try to replace it

p-himik14:12:21

Yeah, Reagent reacts only to changes of its own atoms, which are also often called ratoms.

DerTev14:12:27

Works now, thanks!

👍 1