Garrett Floyd
How do you get createAsync to refetch or mutate?
Thanks for your help again. I have been suspicious that I have been messing up the preload syntax somehow, so that what is preloaded is not connected to what I'm using in my createAsync resource. However, as I looked over my code to prepare a simplified example to get your opinion, I realized I had a "use server" directive at the top of the file I declared my queries in. That seem like a likely source for the problem I'm having and sure enough after removing it everything works as intend.
12 replies
How do you get createAsync to refetch or mutate?
Ends up that the function body within createAsync is a reactive context so calling a signal there will trigger a refetch. Thankfully useSubmission outputs a signal based entity, so when my action resolves and gets a result it reads it into the useSubmission resource which then retriggers the createAsync resource as a derived signal, refetching the data.
12 replies
How do you get createAsync to refetch or mutate?
const refreshTable = useSubmission(delEntryAction);
let tableEntries = createAsync(() => { let data; if (refreshTable.result === undefined){ data = getInitFetch(props.apiURL, limit(), pageNum()); } else { data = refreshTable.result; } return data; });
let tableEntries = createAsync(() => { let data; if (refreshTable.result === undefined){ data = getInitFetch(props.apiURL, limit(), pageNum()); } else { data = refreshTable.result; } return data; });
12 replies
How do you get createAsync to refetch or mutate?
Thanks for the help everyone. The consensus seems to be that the helper functions like revalidate and reload should automatically cause the the createAsync based resource to refetch. However, this is not what I'm seeing. I did however find another solution. Consider the following code snippet
12 replies
How do you get createAsync to refetch or mutate?
I just wanted to add that my initial assumption was that using one of the helper functions to invalidate the cache of the query would cause the createAsync based resource to update the UI but I've tried using reload, revalidate, and redirect for good measure in the return of my action and it hasn't been working so far.
12 replies