Fork me on GitHub

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!


did you use comp/factory?


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]}


didn't work 😕


@tony.kay my queries are ok, Im logging stuff and the data shows


its just the router target component that is not being re-rendered


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


that’s it…either your query is wrong or your state is


there is nothing else


but why does it work if I create the component manually, without the router?


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


the router one doesn't


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.


I appreciate your help, I'm pretty sure the error is on my side


this is a project I'm using to learn fulcro so there's probably alot of things that are not idiomatic


Give each of your router targets an :initial-state {}


well, the video target won’t work with that, since your ident is dependent on data…


didnt' work


tks for the help though


Im pretty sure i still havent grasped the query, ident and normalization stuff and Im doing something wrong


if there is nothing for an item, leave it out


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


I probably got the ident concept wrong


I'll try to fix some stuff when I get home


Btw real root is in root.clj


The current route thing is probably badly wired that's why I put that todo


Btw I was passing props down because that's what I do in plain react


@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


so I either screwed up the query and/or ident


@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


watch the videos, if you have not…the first few esp.


I was aiming for a flat model before trying to use dynamic idents, so in my mind every query would fetch from root and every transact would write to root


ok, I prefer reading but will watch then