This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-09-20
Channels
- # aleph (1)
- # announcements (1)
- # aws (11)
- # babashka (117)
- # beginners (34)
- # calva (13)
- # cider (3)
- # clj-commons (8)
- # clj-kondo (24)
- # clj-yaml (36)
- # cljsrn (46)
- # clojure (50)
- # clojure-australia (5)
- # clojure-europe (239)
- # clojure-nl (3)
- # clojure-norway (3)
- # clojure-spec (16)
- # clojurescript (25)
- # core-typed (20)
- # cursive (41)
- # datahike (1)
- # datalevin (1)
- # datomic (17)
- # fulcro (27)
- # hyperfiddle (35)
- # introduce-yourself (1)
- # jobs (4)
- # lsp (20)
- # malli (8)
- # meander (8)
- # nbb (1)
- # off-topic (31)
- # parinfer (9)
- # pathom (3)
- # portal (2)
- # re-frame (20)
- # react (2)
- # reagent (8)
- # releases (1)
- # remote-jobs (4)
- # scittle (2)
- # shadow-cljs (8)
- # slack-help (4)
- # sql (30)
- # squint (3)
- # tools-deps (34)
- # xtdb (21)
When I route-to a report component with an uuid as props with rroute/route-to!
the network tab in fulcro inspect correctly sends it as an #uuid "blabla"
(rroute/route-to! this AccountInvoices {:account/id (new-uuid 101)})
But when I route-to an defsc component, as this part of the book https://book.fulcrologic.com/#_live_router_example, with dr/change-route
it loads the string "ffffffff-ffff-ffff-ffff-000000000101"
Route parameters arrive to :will-enter
as strings and you need to coerce them to a different type if that's what you need. In the Person
component you can see this:
:will-enter (fn [app {:person/keys [id] :as route-params}]
(log/info "Will enter user with route params " route-params)
;; be sure to convert strings to int for this case
With rroute/route-to!
you pass a params map and it receives it exactly as is. That's the difference.
okay! any ideas how i could convert this string into a java.util.UUID? (in the cljc file)
Yes, use this https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/ids.cljc#L56-L59 like (id-string->id :uuid uuid-str)
The component works and loads it's query correctly, but
dr/change-route
doesn't seems to change the url path
Indeed, it does not. In Fulcro, unlike other similar framework/libraries, the notions of routing and URL management are separate. This is largely because Fulcro is designed to be UI agnostic. RAD's routing helpers tie in the HTML5 history/URL control, but otherwise you need to take care to manage the URL yourself. See the com.fulcrologic.rad.routing.history
ns for some helpers.
This recent post explains it in more detail https://clojurians.slack.com/archives/C68M60S4F/p1661886186549229?thread_ts=1661858678.861289&cid=C68M60S4F.
Take a look at the source for rroute/route-to!
. That might serve as a useful example https://github.com/fulcrologic/fulcro-rad/blob/develop/src/main/com/fulcrologic/rad/routing.cljc#L42-L45
Why is hooks/use-effect
a macro but hooks/use-callback
and hooks/use-memo
aren't?
https://github.com/fulcrologic/fulcro/commit/c8cb41357348b76c91b3ca3f1c22da584dce2607?diff=split#diff-5e609b3b38d49935b486f5ebd41980cc22993c21ed6294795c22674354b107a1R48
Because it is messing with low-level js values at compile time. JSValue
is the cljs compiler’s rep of #js
data before it is converted to low-level source. This allows the macro to seamlessly pass-through a js argument to use-effect, and to convert a CLJ data structure for dependencies through as a js value without needing runtime conversion.
so using #js [a b c]
as deps is identical to using [a b c]
in terms of performance, and there is no intermediate clj data structure in the mix at runtime
This I get, but are you saying use-callback and use-memo do not need this kind of optimization?
and probably the fact that the actual overhead is so small to be insignificant so I didn’t bother…useEffect seems like a heavily used one. I think I wasn’t the only person doing those…
I think as I was writing use-root and use-component and use-uism it seemed to me like use-effect was being called a lot, and so it bothered me that the deps were being reconverted on every render