CreateResource Not complete Fetch (promise) when page first loads, but completes when VsCode Saves
Hey I'm severely confused about what's happening under the hood for npm run dev. When I'm using createResource(fetcher) and do a console.log(response) in the fetcher function, the data gets printed out in my VSCode terminal only. But once when I hit save without changing anything, it will show up in the console of my browser (chrome). Does anyone know what is happening to cause this?
My example:
9 Replies
It looks that the first call is could be running server side - but that's a vague assumption, given that there's almost no information in your post. Add more details.
Thanks for the feedback! I added an example to my question and yea it's definitely happening on the server side. How do I get the results from the server to happen on the frontend?
Also, I though that everything would just be passed down from the server to the frontend automatically?
I would guess that it has to do with defaults on createResource when running in SSR, there's ssrLoadFrom
GitHub
solid/CHANGELOG.md at 57f4d513e2798eddabb1700e00ed7ec8a63725de · so...
A declarative, efficient, and flexible JavaScript library for building user interfaces. - solid/CHANGELOG.md at 57f4d513e2798eddabb1700e00ed7ec8a63725de · solidjs/solid
Try to set it up the way you want it
adding { ssrLoadFrom: 'initial' } would not fetch server side, and instead use the initial value.
Thank you so much for this. You don't know how long I've been trying to figure this out.
Not an expert on SolidStart at all, but glad to be of help.
Still much appreciated. One of the issues for me is I'm still incredibly knew to the whole solid/react world so reading documentation is often times above my understanding
After consuming several live streams I have an updated solution that works and is simple to understand.