This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-01
Channels
- # adventofcode (1)
- # announcements (10)
- # babashka (13)
- # beginners (104)
- # braveandtrue (2)
- # calva (5)
- # clj-kondo (23)
- # cljdoc (8)
- # clojure (10)
- # clojure-finland (1)
- # clojure-greece (1)
- # clojure-norway (2)
- # clojure-sweden (7)
- # clojure-uk (29)
- # clojurescript (20)
- # community-development (12)
- # cursive (4)
- # datomic (1)
- # duct (2)
- # emacs (24)
- # fulcro (48)
- # off-topic (5)
- # pathom (2)
- # planck (2)
- # quil (3)
- # reagent (17)
- # reitit (7)
Hi Happy New Year everyone! I have made a lot of progress using Fulcro. I am trying to make a child of a child, initializing data from the top child's fields. I can't seem to make this work -- I keep getting A Fulcro component was rendered outside of a parent context
but I used defsc
to create the component. Can anyone give me some examples to look at? Thanks in advance!
@hadilsabbagh18 probably this: http://book.fulcrologic.com/#_the_function_as_a_child_pattern
I'm also having issues with a router; apparently the props are not being passed to the router targets; I guess i dont quite understand how it works
((comp/factory videos/Root) props) ;;<< renders OK
(ui-root-router router) << has router-targets videos/Root, but the videos/Root component doesnt refresh with the data it askeed for in the query
@mping Compose initial state and query to root, or make sure you put the proper state in the client db manually. db generation cannot happen if you don’t compose things to root…also matters that you properly compose the query. Basically: if something like that doesn’t work it probably means you messed up composing query/initial state, or ident is funky somehow.
well this is a weird case, because I'm pushing data from an electron main process to the renderer
I guess I have to say that a component needs to be updated; gonna try transacting with {:refresh [query]}
trace through the app state and make sure the tree makes sense that you’re expecting
render is the following: 1. Convert the db (from root or the component being refreshed) into a tree 2. Pass the props to the root (or component being updated).
in the example I gave:
((comp/factory videos/Root) props) ;;<< renders OK
(ui-root-router router) << has router-targets videos/Root
so its basically the same component on both of them, and the first one always re-render when data is updated
I use the router in many many apps. It works. I don’t know what else to tell you. I cannot guess what you’re doing wrong. You could post your source and one of us could possibly point out the problem.
here's the code https://github.com/mping/observideo-app/blob/master/src/electron/com/observideo/renderer/components/root.cljs#L83
this is a project I'm using to learn fulcro so there's probably alot of things that are not idiomatic
Im pretty sure i still havent grasped the query, ident and normalization stuff and Im doing something wrong
OK, I don’t think this is true: https://github.com/mping/observideo-app/blob/master/src/electron/com/observideo/renderer/components/root.cljs#L35
I don’t recommend using nil
like this in initial state: https://github.com/mping/observideo-app/blob/master/src/electron/com/observideo/renderer/components/root.cljs#L38
OK, so you say that it works when you given it “props” but not “router”, and that does not make any sense. You should never ever pass props
as you’ve declared them to any child
and you say that you’re pushing data from the server…so that makes me think that you just are not making the data model correct. You’ve named too many things Root
for my taste, and I don’t want to search through your code for what is the real root of you application, but if you follow the database linkage from that real root down, you should be following idents to create the tree…as shown in the early videos when I demo db->tree
. That’s really all there is to it. If you get the data model correct, then the query can be resolved, and if the query is correct (and I see nothing wrong in this section of code with that) then the only reason for it not to render is that you are not connecting the dots in the data model @mping.
Thanks for taking a look, I followed the book but haven't manage to get the repl working
@mping you do pass props down, but you pass the correct props down…the props that go with a given component. If you’re rendering the router, you want to pass the router;s props, not the parent’s (which is what you example implied)
my guess is that it didn’t actually “work” so much as passed non-nil data to the child which caused it to render something
well I though/assumed f the :query
was correct I was fetching from root, so it would be the same as passing root's props
@tony.kay I still havent quite grasped how the query and ident play together; queries are colocated but I didnt figure out how fulcro manages to get the data; meaning how is the data supposed to be transacted