fulcro

mitchelkuijpers 2025-04-04T11:38:34.075049Z

I came into a situation where are reaching for the "Fulcro Raw" but for some reason it seems the add-component! hooks don't work. I made a very small example based on the docs and it seem add-component! does not do anything:

(defonce app2 (rapp/fulcro-app {:id "raw-fulcro-hooks"}))

  (def Address (rc/nc [:address/id :address/street]
                      {:componentName ::Address
                       :initial-state (fn [{:keys [id street]}] {:address/id id :address/street street})
                       :ident         (fn [this props] [:address/by-id (:address/id props)])}))

  (def Person (rc/nc [:person/id :person/name {:person/address (rc/get-query Address)}]
                     {:componentName ::Person
                      :initial-state (fn [_]
                                       {:person/id      10
                                        :person/name    "Bob"
                                        :person/address (rc/get-initial-state Address
                                                                              {:id     20
                                                                               :street "111 Main"})})}))

  (rapp/add-component! app2 Person {:initialize?    true
                                             :keep-existing? true
                                             :receive-props  (fn [props]
                                                               (js/console.log "RECEIVE PROPS")
                                                               (js/console.log props))} )
  ;; prints Receive PROPS

  (merge/merge-component! app2 Address {:address/id     20
                                       :address/street "wow"})

  ;; Prints nothing

  (rapp/current-state app2)
  ;; =>
  ;;{:address/by-id {20 {:address/id 20, :address/street "wow"}},
  ;; :person/id
  ;; {10
  ;;  {:person/id 10,
  ;;   :person/name "Bob",
  ;;   :person/address [:address/by-id 20]}}}

tony.kay 2025-04-04T13:17:17.206589Z

Make the file CLJC and try it in a CLJ REPL…curious what you find

mitchelkuijpers 2025-04-04T13:23:34.275849Z

Interesting it works in a clj repl

tony.kay 2025-04-04T13:25:50.005619Z

ok, so that’s interesting

tony.kay 2025-04-04T13:26:06.149539Z

it may be I never tested it in CLJS facepalm

mitchelkuijpers 2025-04-04T13:26:27.327239Z

If you have any tips I am happy to test out in CLJS

tony.kay 2025-04-04T13:26:33.311709Z

but not sure off the top of my head what it could be…the diffs should be subtle if any

tony.kay 2025-04-04T13:26:46.864529Z

BTW, long-time no see, how ya been?

mitchelkuijpers 2025-04-04T13:27:13.702569Z

Very good, how are you? I am still working at Avisi and having fun 😄

tony.kay 2025-04-04T13:27:47.788429Z

doing pretty well. Busier (in a more chaotic way) than I used to be, but have good luck in general.

tony.kay 2025-04-04T13:28:34.520339Z

On this bug: I usually do a :local/root in deps or just make new cards in the fulcro repo itself and trace through the code. There’s not much to the overall render pipeline, so it should be relatively easy to uncover

mitchelkuijpers 2025-04-04T13:29:29.377489Z

I'll take a stab at it then

tony.kay 2025-04-04T13:29:33.748749Z

thanks

mitchelkuijpers 2025-04-04T13:29:52.866669Z

Btw really love this API since we need to integrate with very custom Atlassian react stuff

tony.kay 2025-04-04T13:30:52.617519Z

Glad to hear it’s useful in addl contexts. The original target was CLJ without React as an experiment…

tony.kay 2025-04-04T13:31:26.255229Z

which explains the potential lack of testing in CLJS…though MOST of the code is original (moved from the non-raw ns and referred to from there)

tony.kay 2025-04-04T13:31:51.086929Z

my guess is that something in raw.application is different

mitchelkuijpers 2025-04-06T11:49:49.341069Z

I found the issue, apparently in this instance where need to run in a sandboxed js env in a browser they define js/requestAnimationFrame but it never calls the callback

mitchelkuijpers 2025-04-06T11:49:55.125749Z

So no bug on Fulcro's side

👍 1
tony.kay 2025-04-06T15:51:17.853119Z

thanks for letting me know

👍 1
tony.kay 2025-04-04T13:15:14.376109Z

you’re saying you see no props?

Yaw Odame 2025-04-04T19:40:34.956609Z

Anyone else seeing dynamic router 3.8.3 with fulcro 3.8.3. Wondering if I have something misconfigured.

tony.kay 2025-04-04T20:50:39.640789Z

?

tony.kay 2025-04-04T20:50:48.236079Z

don’t understand your question at all

Yaw Odame 2025-04-11T15:35:19.892359Z

I think this is a user error. Sorry for the bother.