This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-19
Channels
- # admin-announcements (1)
- # adventofcode (14)
- # announcements (2)
- # asami (7)
- # babashka (9)
- # beginners (41)
- # calva (43)
- # cider (31)
- # clerk (2)
- # clojure (34)
- # clojure-europe (17)
- # clojure-nl (1)
- # clojure-norway (166)
- # clojure-uk (7)
- # clojurescript (4)
- # datomic (1)
- # fulcro (10)
- # garden (1)
- # hoplon (2)
- # humbleui (4)
- # hyperfiddle (12)
- # jobs-discuss (6)
- # quil (6)
- # ring (6)
- # shadow-cljs (55)
- # squint (8)
- # xtdb (26)
I have a defsc with a route-segment [:course/id], :course/id is also the ident Now this components has 2 tabs which I'm trying to implement with a defrouter, but how can I pass the :course/id down?
ok so I got it to work with a combination of will-enter on the child and pre-merge on the parent, but I have no idea what I am doing. I was trying to follow these two resources but I have a hard time understanding. https://book.fulcrologic.com/#_composing_the_routers_state_into_the_parent https://blog.jakubholy.net/2020/fulcro-divergent-ui-data/#_inserting_a_stateful_ui_component_between_a_parent_child_entities @U0522TWDA it would be awesome to have a working example of this one and maybe some extra explanation
It's a little dangerous to have a route segment that doesn't include some sort of unique constant component, because doing so means that other siblings that do the same thing will then be ambiguous. That said, route parameters are passed as the params argument to dynamic routing calls. They will come to will enter as strings, independent of the type that you would actually like. I believe the dynamic routing chapter covers all of this
+1 to what Tony said. You most likely want rather something like :route-segment ["course" :course/id]
on the parent component.
I assume the problem you are facing is that the child tabs have route segments something like ["tab1"]
and ["tab2"]
? I do not remember whether route-params
in the tab’s :will-enter
have the full route params (thus including the parent’s :course/id
or not). Do they?
I believe that I have previously solved it by passing an ID like this from a parent component down to descendants as a computed prop, see :organization/organization-number
in https://github.com/holyjak/fulcro-billing-app/blob/main/src/shared/billing_app/ui/billing/ui.cljc#L497-L498
@U0522TWDA interestingly it is called more than once and at first the params that are part not part of the component segment are not there
Am I right in thinking that computed properties are only needed for components that have an ident and query? For components that are just glorified defn
s producing only UI data, is it fine to pass properties such as functions and whatnot in the main props, or should they be declared as computed props? I see the fulcro template uses defn for this kind of thing, so should I use that rather than defsc?
that's a great question I was wondering the same!
Correct. Computed allows fulcro to keep track of which things it found for the component versus which things you added in. If fulcro did not provide any of the props, then there is no need to separate them.
Optimizations that Target rendering at components with idents need to be able to generate new props that include whatever the parent last passed to them. If the computed props are not marked, then such refreshes will look as if the parent add-ons disappear during an optimized refresh
Thank you.