SolidJSS
SolidJSโ€ข16mo agoโ€ข
9 replies
mrVinicius

Stores & CreateResource

Why createResources doesn't work with a store?
console.log("currentPageParam", params.currentPage) properly shows me that the store itself is being updated, but the signal change is not being passed into createResource like with a regular signal does. If instead i use a regular signal currentPage() the signal is triggered on createResource, what i am missing?
const pagination = createPagination();
const [params, setParams] = createStore<ConstructionCatalogItemListParams>();
const [currentPage, setCurrentPage] = createSignal<Record<string, string>>();
const [itemResource] = createResource(params, constructionCatalogItemList);

createEffect(() => {
        // here i am updating my store query params values, these values are coming from pagination context.
    setParams((prev: ConstructionCatalogItemListParams) => {
                // setCurrentPage is a signal as my plan B, this shouldn't be here if stores worked
        console.log("currentPage:", pagination.currentPage());
        setCurrentPage({ currentPage: pagination.currentPage().toString() });
        return {
            ...prev,
            currentPage: pagination.currentPage(),
        };
    });
        // params was successfully set.
    console.log("currentPageParam", params.currentPage);
});
Was this page helpful?