Skip to content

undefined initial value changes initial resource state to refreshing #1725

@thetarnav

Description

@thetarnav

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions