I ran into an issue with dynamic routing after upgrading fulcro.
In 3.2.4 the order of route-deferred actions was changed to depth-first to prevent flickering.
I have the following nested route in my app:
Component
segment: “/contacts/:id”
Child Component A
segment: “/files”
Child Component B
segment: “/comments”
Now when I route to “/contacts/1/files” I will get the deferred-route action to load data on the files screen first. But that does not get the :id
route-param to know for which contact to load those files.
Is there a way to retrieve that route param in dynamic routing in the nested route?
Interesting. I would make the case that the overall route is a global bit of info, but the localized concern of composable routers means I don't want to confuse the local parameters with the global. I'd say it is best for you to parse URL yourself to make parameters part of your app state so you can use them as the global info they are in this kind of case.
I figured that would be the best solution, thanks.
I'm pretty new to fulcro, but when trying to make a purely presentational component: (comp/children this)
skips the first child, so the returning list is just the rest of the children.
If it is related, my project is on version: react@17.0.1
and com.fulcrologic/fulcro@3.4.4
Tip: Always use the latest Fulcro. It is almost always backwards compatible and provides better dev help. BTW, have you seen https://fulcro-community.github.io/guides/tutorial-minimalist-fulcro/ ? I am always looking for feedback 🙂
Not sure if I'm missing something, but this is the sample of my code
(ns app.client.components
(:require
[com.fulcrologic.fulcro.dom :as dom]
[com.fulcrologic.fulcro.components :as comp :refer [defsc]]))
(defsc Card [this props]
{}
(dom/div :.border-2.p-4.mx-8
; props ;; renders (dom/h3 "Main") => is props is first child?
(comp/children this))) ;; renders [(dom/p "...")]
(def ui-card (comp/factory Card))
(defsc Main [this props]
{:query [:main/welcome-message]
:initial-state (fn [_] {:main/welcome-message "Hi!"})
:ident (fn [] [:component/id :main])}
(ui-card
(dom/h3 "Main")
(dom/p (str "Welcome to the Fulcro template."))))
try passing in an empty map to the first arg like (ui-card {} ...)
you can see in definition of comp/factory
that it returns a function with the signature [props & children]
Thanks, that did it. Must've missed that detail
if you think about it, fulcro can't know whether the first arg is the props map or a child