Why is this page with `useParams` and `createResource` not reloading?
When I switch pages, the
params.id log is changing, but createResource is not calling the fetchArticle() function again.
The docs https://www.solidjs.com/docs/latest/api#createresource say:
t will be called again whenever the value of sourceSignal changes, and that value will always be passed to fetchData as its first argument.
SolidJS
Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.
3 Replies
You might need to use
() => params.id as the source, rather than just useParams().idthanks, I had tried
const id = () => useParams().id; and createResource(id(), fetchArticle); before, but now I see that I should have used createResource(id, fetchArticle); 🤦♂️Yep, otherwise the getter is being called outside of the resource's context, so it isn't tracked by it