SolidJSS
SolidJSโ€ข3y agoโ€ข
3 replies
Bersaelor

Why is this page with `useParams` and `createResource` not reloading?

export default function ArticleDetail() {
  const [article] = createResource(useParams().id, fetchArticle);

  createEffect(() => {
    if (article())
      console.log("params.id ", useParams().id);
  });

  createEffect(() => {
    if (article())
      console.log("Finished loading ", article()!.title);
  });

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.
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.
SolidJS
Was this page helpful?