beganovich
Good pattern for refetching the data
Hi folks,
What would be a good way to trigger refetch outside the component?
I tried extracting the createResource outside the Tasks component, but that means it'll fetch as soon as component is imported.
Is there a better way other than passing down the props?
Here's example:
https://playground.solidjs.com/anonymous/734acabf-e069-4043-9db2-bf5b014b0691
3 replies
Manually refetching server data, causes double request
Hi,
I was wondering if this is correct behavior or am I missing something.
There's following code:
So, as you can probably guess, once we load the page, it fetches some data from server. In this case just randomly generated number.
Now, let's imagine I have "Refetch" button that should.. you guessed it.. refetch the data. However, the problem is - two requests.
I assume one is for the actual route action call and second for page load, or something?
Can someone explain why am I seeing two requests & how to prevent this?
Edit:
Calling "refetchRouteData" directly in button causes one request, but what if I need it in action?
2 replies