Fork me on GitHub
#fulcro
<
2020-01-01
>
hadils17:01:32

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!

mping21:01:21

did you use comp/factory?

mping21:01:49

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

mping21:01:56

((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

tony.kay22:01:16

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

mping22:01:42

well this is a weird case, because I'm pushing data from an electron main process to the renderer

mping22:01:55

I guess I have to say that a component needs to be updated; gonna try transacting with {:refresh [query]}

mping22:01:41

didn't work 😕

mping22:01:21

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

mping22:01:34

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

tony.kay22:01:07

trace through the app state and make sure the tree makes sense that you’re expecting

tony.kay22:01:49

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

tony.kay22:01:58

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

tony.kay22:01:00

there is nothing else

mping22:01:51

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

mping22:01:11

in the example I gave:

((comp/factory videos/Root) props) ;;<< renders OK
(ui-root-router router) << has router-targets videos/Root

mping22:01:34

so its basically the same component on both of them, and the first one always re-render when data is updated

mping22:01:37

the router one doesn't

tony.kay22:01:22

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.

mping22:01:09

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

mping22:01:59

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

tony.kay23:01:46

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

tony.kay23:01:17

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

mping14:01:50

didnt' work

mping14:01:57

tks for the help though

mping15:01:49

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

tony.kay17:01:04

if there is nothing for an item, leave it out

tony.kay17:01:02

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

tony.kay17:01:21

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.

mping18:01:46

Thanks for taking a look, I followed the book but haven't manage to get the repl working

mping18:01:04

I probably got the ident concept wrong

mping18:01:38

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

mping18:01:53

Btw real root is in root.clj

mping18:01:40

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

mping18:01:24

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

tony.kay19:01:40

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

tony.kay19:01:02

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

mping20:01:01

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

mping20:01:12

so I either screwed up the query and/or ident

mping20:01:33

@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

tony.kay20:01:08

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

mping20:01:17

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

mping20:01:25

ok, I prefer reading but will watch then