`undefined` initial value changes initial resource state to `refreshing`
Describe the bug
Normally The resources start at "rending" state before they become "ready". When the initial value is passed the resources start at "refreshing", as it's considered a subsequent request of sorts.
But passing undefined as the initial value — e.g. when creating a custom primitive with createResource and passing the user's parameter strength through as the initial value, which by default will be undefined — results in the "refreshing" initial state. Which seems a bit odd as undefined kinda reads as "user did not defined an initial value" 🙃
So I'm wondering if this is intended as we got an issue on solid-primitives because of this behavior.
Interestingly, the solution to fix this on our side is to check initialValue !== undefined and not pass the property at all if it's not defined, which is funny because this is exactly what I would expect resources to do instead of pushing this problem downstream.
Your Example Website or App
https://playground.solidjs.com/anonymous/dcf0dc7e-6f56-4b30-be43-ed0a850190a4
Steps to Reproduce the Bug or Issue
Look at the console
Expected behavior
Both resources should have the same initial state
Hmm... this sort of stuff is always tricky because if we say undefined is fine then someone will argue that we are special casing undefined. Like what if you wanted undefined as the initial value. I don't necessarily see an issue but I made this call at the same time people were trying to argue that errors could be undefined and still be errors. We've obviously backed off that stance but if we do change this someone will undoubtedly say this was what they were intending. Have to decide how ok we are with that.
I think the issue in solid-primitives and the behavior of createResource() are subtly different. createResource() takes an options object where the initialValue property is optional. I can see people reasoning that if the property is missing then the resource starts in an uninitialized state but if the property is given its value does not matter: even if it is undefined the existence of the property is enough to put the resource in the initialized state.
This complicates the downstream code (as my patch to solid-primitives shows) but if a lot of people expect this behavior I don't see any solid argument to change how createResource() works.