fulcro

Book: http://book.fulcrologic.com, Community Resources: https://fulcro-community.github.io/, RAD book at http://book.fulcrologic.com/RAD.html
timovanderkamp 2021-06-08T12:32:41.138100Z

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?

tony.kay 2021-06-08T13:06:16.138200Z

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.

timovanderkamp 2021-06-08T13:24:56.138800Z

I figured that would be the best solution, thanks.

Kelvin Mai 2021-06-08T20:24:26.142500Z

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

Jakub Holý 2021-06-09T08:19:43.143800Z

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 🙂

Kelvin Mai 2021-06-08T20:32:05.142600Z

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."))))

nivekuil 2021-06-08T20:34:43.142800Z

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]

👍 1
Kelvin Mai 2021-06-08T20:37:59.143200Z

Thanks, that did it. Must've missed that detail

nivekuil 2021-06-08T20:41:17.143400Z

if you think about it, fulcro can't know whether the first arg is the props map or a child

👍 1