Can't use `useRouteData`

Hi guys, I'm using basic routing without FileRouter and whenever I'm trying to use useRouteData inside of my component, I'm getting Make sure your app is wrapped in a <Router /> , without using it, everything works just fine. Do you have an idea what can be the issue? I've got a lazy component inside <Route component={
8 Replies
thetarnav
thetarnav15mo ago
are you passing the data function to the data prop? does it work when the component is not lazy?
aquarazorda
aquarazorda15mo ago
@thetarnav yes and no I've tried without lazy import, nothing seems to work . Whenever I comment the useRouteData, query function runs as well and everything's fine. I just want to know, what can be the cause of that kind of behaviour. I'm creating Solid components in kinda different way so to say, without JSX.
thetarnav
thetarnav15mo ago
can you screenshot the router & component code? from what I understand route data is a fully runtime mechanism, so JSX shouldn't be important or, if you call useLocation or any other primitive that hooks into existing router in that component, do you get the same error, or is it only with useRouteData?
aquarazorda
aquarazorda15mo ago
For demonstration purposes I've moved Route component back to solid and now Component is PureScript generated component, which is being composed with the functions of second screen. so basically my Component is a function, which returns createComponent and inside createComponent's function, I have useRouteData
thetarnav
thetarnav15mo ago
how do you use dynamic?
thetarnav
thetarnav15mo ago
this doesn't look right
thetarnav
thetarnav15mo ago
I would always do
get children() {
return cs
}
get children() {
return cs
}
also I feel like this is important ☝ because if the children are executed too early - not by the <Router> but by the <Route> or something like that, none of the Router hooks will work
aquarazorda
aquarazorda15mo ago
I’m using dynamic to create basic dom nodes, div, span, etc… Regarding children being executed before, when I’m logging something from that component, I only see those logs, whenever I’m getting redirected to that page, so I don’t think that they are executed earlier. Will check it out a bit later, thanks for your time. I’ll get back soon. useLocation doesn't work as well, I guess something's executing too early and that's causing the issue? @thetarnav but that seems like illogical, my Router invocation is waay up there. I'm using SolidStart template and as you can see, that Component is being called even under Routes I had SolidStart project and Purs project in different folders with different node_modules, that was the issue 🤦‍♂️