Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Experimental] Support promises as fallback data #2891

Merged
merged 9 commits into from
Feb 16, 2024
Merged

[Experimental] Support promises as fallback data #2891

merged 9 commits into from
Feb 16, 2024

Conversation

shuding
Copy link
Member

@shuding shuding commented Feb 16, 2024

This PR introduces the ability to accept promises as fallback data for SWR read hooks. The behavior is that the resolved value of the promise will be used as fallback instead of the promise itself.

The resolution of the promise is implemented via use which means that it will suspend the upper boundary.

Copy link

codesandbox-ci bot commented Feb 16, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@shuding shuding marked this pull request as ready for review February 16, 2024 14:49
@shuding shuding requested a review from huozhi as a code owner February 16, 2024 14:49
Copy link
Collaborator

@promer94 promer94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid upgrading react to a specific version here?

we currently have a spearte testing workflow for react@canary at https://github.com/vercel/swr/actions/workflows/test-canary.yml

so i guess we could create a sperate jest config for this and only test it in react canary ?

src/core/use-swr.ts Outdated Show resolved Hide resolved
test/use-swr-promise.test.tsx Outdated Show resolved Hide resolved
@huozhi huozhi merged commit cfcfa9e into main Feb 16, 2024
8 checks passed
@huozhi huozhi deleted the shu/agil branch February 16, 2024 20:53
@huozhi huozhi added this to the v3 milestone Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants