Fork me on GitHub
#fulcro
<
2022-10-04
>
zhuxun204:10:40

It seems that in order for Fulcro to work with React v18's root = ReactDOM.createRoot(node) -> root.render(...), there needs to be some changes to the mount! function as it needs to redo the ReactDOM.createRoot for some reason.

Joe R. Smith14:10:29

I'm a little rusty on Fulcro + defrouter + loading .. I'm calling load in the :will-enter function of a route target component. I want to load a collection/list of items. E.g., Root -> Router -> RoutedComponent, with an ident of [::component/id ::RoutedComponent]. Assuming I'm trying to load a list of people: The examples I've found suggest calling load like this: (df/load app ident RoutedComponent) which would generate a remote query like [{[::component/id ::RoutedComponent] [{:people/list [:person/id :person/name]}]}], but my pathom API needs just [{:people/list [:person/id :person/name]}] . Can someone point me at an example?

tony.kay15:10:14

(df/load :people/list Person {:target [:component/id ::RoutedComponent :people-field-for-list-join]})

tony.kay15:10:10

Loads are always relative. You’re always loading some sub-tree. So, you specify it as if it were at root (which is what EQL wants for remote interaction) and then target the result at the ident + field of the location it should land

tony.kay15:10:19

very outdated (wrong lib name, etc) but still relevant white-board discussion: https://youtu.be/mT4jJHf929Q

Joe R. Smith22:10:47

I'm doing as described above, the data is coming back from my server, but my User component is getting an empty map for props so normalizing using :user/id is giving me nil. I'm getting back several dozen persons from the server query, but ending up with a single "nil" person (`[:user/id nil]`) in the client db. My User component:

(defsc User
  [this {:user/keys [id] :as props}]
  {:ident (fn []
            (println "id: " id)
            (println "props: " props)
            [:user/id id])
   :query [:user/id :user/email]})
My load:
(df/load! app
          :redacted/users
          User
          {:target (conj [:component/id ::MainPage] :redacted/users)})
My DB:
{:com.fulcrologic.fulcro.ui-state-machines/asm-id
 {:com.redactedcompany.admin-dashboard.ui/MainRouter
  {:com.fulcrologic.fulcro.ui-state-machines/asm-id
   :com.redactedcompany.admin-dashboard.ui/MainRouter,
   :com.fulcrologic.fulcro.ui-state-machines/state-machine-id
   com.fulcrologic.fulcro.routing.dynamic-routing/RouterStateMachine,
   :com.fulcrologic.fulcro.ui-state-machines/active-state :routed,
   :com.fulcrologic.fulcro.ui-state-machines/ident->actor
   {[:com.fulcrologic.fulcro.routing.dynamic-routing/id
     :com.redactedcompany.admin-dashboard.ui/MainRouter]
    :router},
   :com.fulcrologic.fulcro.ui-state-machines/actor->ident
   {:router
    [:com.fulcrologic.fulcro.routing.dynamic-routing/id
     :com.redactedcompany.admin-dashboard.ui/MainRouter]},
   :com.fulcrologic.fulcro.ui-state-machines/actor->component-name
   {:router :com.redactedcompany.admin-dashboard.ui/MainRouter},
   :com.fulcrologic.fulcro.ui-state-machines/active-timers {},
   :com.fulcrologic.fulcro.ui-state-machines/local-storage
   {:pending-path-segment [],
    :target
    [:component/id :com.redactedcompany.admin-dashboard.ui/MainPage],
    :path-segment ["main-page"]}}},
 :router
 [:com.fulcrologic.fulcro.routing.dynamic-routing/id
  :com.redactedcompany.admin-dashboard.ui/MainRouter],
 :fulcro.inspect.core/app-id
 "com.redactedcompany.admin-dashboard.ui/Root",
 :fulcro.inspect.core/app-uuid
 #uuid "b8893790-53db-4e1b-826e-7c7942765f7d",
 :com.fulcrologic.fulcro.routing.dynamic-routing/id
 {:com.redactedcompany.admin-dashboard.ui/MainRouter
  {:com.fulcrologic.fulcro.routing.dynamic-routing/id
   :com.redactedcompany.admin-dashboard.ui/MainRouter,
   :com.fulcrologic.fulcro.routing.dynamic-routing/current-route
   [:component/id
    :com.redactedcompany.admin-dashboard.ui/MainPage]}},
 :component/id
 {:com.redactedcompany.admin-dashboard.ui/MainPage
  {:redacted/users [:user/id nil]}},
 :user/id {nil {}},
 :com.fulcrologic.fulcro.components/queries
 {"com.redactedcompany.admin-dashboard.ui/MainRouter"
  {:query
   [:com.fulcrologic.fulcro.routing.dynamic-routing/id
    [:com.fulcrologic.fulcro.ui-state-machines/asm-id
     :com.redactedcompany.admin-dashboard.ui/MainRouter]
    {:com.fulcrologic.fulcro.routing.dynamic-routing/current-route
     "com.redactedcompany.admin-dashboard.ui/MainPage"}],
   :id "com.redactedcompany.admin-dashboard.ui/MainRouter",
   :component-key
   :com.redactedcompany.admin-dashboard.ui/MainRouter},
  "com.redactedcompany.admin-dashboard.ui/MainPage"
  {:query [{:redacted/users [:user/id]}],
   :id "com.redactedcompany.admin-dashboard.ui/MainPage",
   :component-key :com.redactedcompany.admin-dashboard.ui/MainPage}},
 :com.fulcrologic.fulcro.application/active-remotes #{}}

tony.kay03:10:05

:user/id {nil {}},
is clearly wrong

tony.kay03:10:45

what does Fulcro Inspect’s network tab say your server is returning? I think the shape probably does not match (misspelled keywords?)

Joe R. Smith03:10:32

{:redacted/users
 ({:user/id #uuid "86c5e111-8650-457e-b5c8-6e53e1810f10",
   :user/email <redacted email>} ...)}

Joe R. Smith03:10:51

double-checked, everything is spelled the same

Joe R. Smith04:10:48

loading right into root also results in nil user/id and one empty entity, i.e.:

(df/load! app :redacted/users User)

tony.kay04:10:27

Return a vector?

Joe R. Smith04:10:41

from the server you mean?

tony.kay04:10:49

You're returning a lazy seq, cons, or list there

Joe R. Smith04:10:27

This is interesting, if I don't do a join and load into root, it works!

(df/load! app :redacted/users nil)

Joe R. Smith04:10:53

^ that is still returning a list under :redacted/users

tony.kay04:10:57

But it didn't normalize in that case

Joe R. Smith04:10:04

but it populates the :redacted/users table off of root

tony.kay04:10:29

Are you using latest version?

Joe R. Smith04:10:37

I'm hitting a deployed pathom server, so I'll vectorize the list in the response middleware

Joe R. Smith04:10:01

I tried using latest published fulcro-rad, but I was getting that other error I posted

Joe R. Smith04:10:07

(the compilation error)

tony.kay04:10:14

No no. Fulcro

tony.kay04:10:37

Upgrade fulcro

Joe R. Smith04:10:32

ok, trying 3.5.28

Joe R. Smith04:10:22

damn, that fixed it.

Joe R. Smith04:10:38

3.5.6 was the broken version

Joe R. Smith04:10:29

I'll test the theory of it being an issue w/ remote collections being a list

tony.kay04:10:30

Accepting lists was a recent patch

Joe R. Smith04:10:49

ok. 🙂 thank you so much.

Tyler Nisonoff23:10:39

I’m having some trouble with load and :focus with pathom placeholders: my query looks something like:

{:foo/person 
      [{:>/one (comp/get-query OneSC)}
       {:>/two (comp/get-query TwpSC)}}
And what I’d like to do is load this query focusing in on :>/one without it erasing :>/two in the client db under :foo/person Is there such a way to do that? If pathom placeholders aren’t recommended for this, is there some other way to have modular Stateful Components on the same attribute?

tony.kay00:10:33

I don’t understand. Focus on :>one means you don’t want :>two

tony.kay00:10:31

There’s a generalized option for load for transforming the query with an arbitrary function, so you can certainly write your own op

Tyler Nisonoff00:10:36

im focuing on :>one so i dont want :>two updated from the backend, but what i have in the client db under :>two i want to stay there :im focusing on

tony.kay00:10:01

hm. It should

Tyler Nisonoff00:10:10

but since the client db thinks that :foo/person is just a map rather than knowing its a placeholder for an ident, it throws :>two away in the db

tony.kay00:10:22

the query sent should NOT include two, nor should merge clobber it

tony.kay00:10:27

if it does, then that’s a bug

Tyler Nisonoff00:10:37

im seeing it be clobbered in the db

Tyler Nisonoff00:10:43

the query does not include it

Tyler Nisonoff00:10:07

heres what my real db looks like

tony.kay00:10:20

right, I’d have to think on that one. placeholders are not going to work well for you there if OneSC and TwoSC have overlapping items

👍 1
tony.kay00:10:53

if they are disjoint properties, though, I’d think it should work

Tyler Nisonoff00:10:33

it does seem like a bug, where it somehow knows that the individual keys are disjoint properties because they are all idents, but when the load returns, its clobbering them like they are all property

Tyler Nisonoff00:10:54

but not familiar enough with the internals to know if that bug is possible / likely

Tyler Nisonoff00:10:05

prettyyyy sure im doing the right thing here though?

tony.kay10:10:42

I'd need a failing minimal reproducible example to say.

Tyler Nisonoff23:10:30

sounds good, will look into it!

Tyler Nisonoff23:10:50

or some way to specify for the load to merge with the data in the client db rather than overriding?