This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-12-18
Channels
- # adventofcode (26)
- # announcements (3)
- # babashka (12)
- # beginners (20)
- # biff (33)
- # cider (4)
- # clj-kondo (9)
- # cljdoc (17)
- # clojure (35)
- # clojure-art (6)
- # clojure-belgium (1)
- # clojure-denmark (1)
- # clojure-europe (1)
- # clojure-norway (25)
- # clojurescript (29)
- # conjure (19)
- # cryogen (1)
- # datomic (23)
- # honeysql (2)
- # java (3)
- # joyride (9)
- # lsp (24)
- # malli (3)
- # nbb (2)
- # off-topic (25)
- # pathom (2)
- # pedestal (8)
- # portal (1)
- # practicalli (7)
- # re-frame (1)
- # reitit (4)
- # releases (1)
- # shadow-cljs (14)
I noticed the reagent-project have js/undefined
on the tail when every time call react/useEffect
I wonder what's this all about?
@U061V0GG2 Maybe shed some light on this for me, thanks.
useEffect uses the return value if its a function. maybe this is just to ensure no unwanted effects happen. just a guess though
I thought useEffect can return a function to do some cleanup, so this may prevent the cleanup to take effect.
React requires the return value is always either a function or undefined: https://github.com/reactwg/react-18/discussions/95
If you search for it online or here, you'll get about a bazillion results with tips. ;)
Just add ^js
in front of x
.
Any idea, why this doesnt work?
10 | (async/go (swap! current-post assoc
---------^----------------------------------------------------------------------
Cannot infer target type in expression (. inst_12835 -author)
--------------------------------------------------------------------------------
11 | :author-name (get (async-interop/<p! (pb/get-record "users"
12 | (.-author ^js @current-post)
13 | [])) :name)))
So, currently I have
(defn open-post [post-id]
(shadow-modern/js-await [post (pb/get-record "posts" post-id)]
(println (str "post: " post))
(shadow-modern/js-await [author-name (->> ^js post
.-author_name
(pb/get-record "names"))]
(println (str "author-name: " author-name))
(reset! post-view/author-name author-name))
(reset! post-view/current-post post)))
and I get the following output: [img]
Result: <author-name> is printed, when the page renders.
But I want, that author-name is changed, before post-view is rendered. Is this possible in any way?