useParams not updating with urql's createQuery
Currently refactoring a svelte project to Solid. I'm unable to get params to update inside the createQuery() call when you change the dynamic path (ie same route but different fst), which uses urql's solid library. I've tried multiple different variations of making params reactive and none of them seem to work. As you can see in the svelte snippet there, I had to make it derived state so it would update, but the equivalent of
const derivedParams = () => params
doesn't seem to work. Any thoughts?14 Replies
This will depend on how urql’s solid lib works, but you need to pass the value in a reactive manner, arm you’re just passing in the value at the time of execution. Try making the id field a getter
Also I’d get rid of that signal you’re setting into, accessing params is reactive
Uhh so that only sometimes works? I'm not sure if this is now some other part of my code failing
(I removed some of the stuff because while not technically classified it's moderately sensitive haha)
It's hard to say, I'm not sure if that urql lib handles reactivity properly
It doesn't seem like createQuery does, or at least I don't know how to?
Because using just the regular client they provide does
in a createAsync
Hmm it seems like the draft solid bindings for urql have a better implementation of
createQuery
that takes a function as an argument rather than a plain objectWhere are you seeing this?
GitHub
(DRAFT) SolidJS bindings by gksander · Pull Request #2527 · urql-gr...
This PR serves as a didactic to discuss the feasibility of solidjs bindings for urql.
This branch contains initial prototypes for createQuery and createMutation methods that (attempt) to conform to...
though that pr was closed so rip
Ah gotcha. Yeah I might just stick with using the client for now. Thanks though!
FYI: Routes are passed
RouteSectionProps
:
As far as I'm aware:
- props.params
behaves exactly like the accessor returned by useParams
- props.location
behaves exactly like the accessor returned by useLocation
(props.location.query
behaves like the accessor returned from useSearchParams
)The problem is there is no clear way to type props.params
useParams
just uses a type assertion
https://github.com/solidjs/solid-router/blob/50c5d7bdef6acc5910c6eb35ba6a24b15aae3ef6/src/routing.ts#L194GitHub
solid-router/src/routing.ts at 50c5d7bdef6acc5910c6eb35ba6a24b15aae...
A universal router for Solid inspired by Ember and React Router - solidjs/solid-router
Documentation - Everyday Types
The language primitives.
Yes I'm saying I can type useParams. As far as I'm aware there is not an easy way to do the same thing with prop.params? It didn't seem to me like you could specify types easily with mergeProps?