Skip to content

Conversation

@scajal
Copy link

@scajal scajal commented Oct 29, 2025

This PR updates the Deferred component so it will pass the current loading state to the children, when children is a function. It also makes the fallback property optional on the component.

This allows the developer to, for example, show a skeleton while the deferred props are being loaded.

Here's a react example:

<Deferred data="users">
{({ loading }) => (
    <form>
        <select disabled={loading}>
            {users?.map(user => <option key={user.id} value={user.id}>{user.name}</option>)}
        </select>
    </form>
)}
</Deferred>

@scajal scajal marked this pull request as draft October 29, 2025 14:47
@scajal scajal marked this pull request as ready for review October 29, 2025 17:08
@pascalbaljet
Copy link
Member

I'm fine with passing the loading state to the children/slot, but I think making the fallback optional and removing the error is a breaking change. We could make that change in a next major release, though. Could you update the PR to just expose the loading state?

@pascalbaljet pascalbaljet added the needs more info/work Needs more info from the author or additional work to get merged label Oct 30, 2025
@scajal
Copy link
Author

scajal commented Oct 30, 2025

@pascalbaljet With a required fallback this wouldn't make any sense. The fallback would always be rendered if present and the data is still not loaded, so the children would only be rendered after loading the data and the loading property would always be true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs more info/work Needs more info from the author or additional work to get merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants