This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-04
Channels
- # aleph (23)
- # announcements (1)
- # babashka (21)
- # beginners (70)
- # biff (3)
- # cider (8)
- # clj-kondo (45)
- # clj-yaml (9)
- # clojure (69)
- # clojure-europe (82)
- # clojure-nl (1)
- # clojure-norway (2)
- # clojurescript (34)
- # conjure (19)
- # core-typed (6)
- # cursive (2)
- # events (5)
- # fulcro (55)
- # honeysql (1)
- # integrant (18)
- # jobs (1)
- # lsp (124)
- # malli (10)
- # meander (1)
- # off-topic (26)
- # polylith (8)
- # reagent (7)
- # releases (1)
- # remote-jobs (1)
- # sci (2)
- # shadow-cljs (19)
- # squint (5)
- # vim (17)
- # xtdb (31)
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.
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?
(df/load :people/list Person {:target [:component/id ::RoutedComponent :people-field-for-list-join]})
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
very outdated (wrong lib name, etc) but still relevant white-board discussion: https://youtu.be/mT4jJHf929Q
thank you!
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 #{}}
what does Fulcro Inspect’s network tab say your server is returning? I think the shape probably does not match (misspelled keywords?)
{:redacted/users
({:user/id #uuid "86c5e111-8650-457e-b5c8-6e53e1810f10",
:user/email <redacted email>} ...)}
double-checked, everything is spelled the same
loading right into root also results in nil user/id and one empty entity, i.e.:
(df/load! app :redacted/users User)
from the server you mean?
This is interesting, if I don't do a join and load into root, it works!
(df/load! app :redacted/users nil)
^ that is still returning a list under :redacted/users
but it populates the :redacted/users table off of root
right.
I'm hitting a deployed pathom server, so I'll vectorize the list in the response middleware
I tried using latest published fulcro-rad, but I was getting that other error I posted
(the compilation error)
ok, trying 3.5.28
damn, that fixed it.
3.5.6 was the broken version
I'll test the theory of it being an issue w/ remote collections being a list
ok. 🙂 thank you so much.
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?There’s a generalized option for load for transforming the query with an arbitrary function, so you can certainly write your own op
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
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
im seeing it be clobbered in the db
the query does not include it
heres what my real db looks like
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
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
but not familiar enough with the internals to know if that bug is possible / likely
prettyyyy sure im doing the right thing here though?
sounds good, will look into it!
or some way to specify for the load to merge with the data in the client db rather than overriding?