Repository navigation
feat(react): support fallback callbacks in Suspense.with - #1954
KimHyeongRae0 wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 16b1bbc The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
People can be co-author:
|
|
@KimHyeongRae0 is attempting to deploy a commit to the Toss Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1954 +/- ##
==========================================
+ Coverage 93.22% 93.25% +0.03%
==========================================
Files 42 42
Lines 664 667 +3
Branches 163 165 +2
==========================================
+ Hits 619 622 +3
Misses 42 42
Partials 3 3
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The callback currently executes eagerly even when the fallback is not rendered.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds prop-aware fallback callbacks to Suspense.with.
Changes:
- Adds callback fallback typing and resolution.
- Adds runtime coverage and a patch changeset.
File summaries
| File | Description |
|---|---|
packages/react/src/Suspense.tsx |
Implements callback fallbacks. |
packages/react/src/Suspense.spec.tsx |
Tests prop-based fallback rendering. |
.changeset/suspense-with-fallback-callback.md |
Records the patch release. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| (props: TProps) => { | ||
| const { fallback, ...restSuspenseProps } = suspenseProps | ||
|
|
||
| return ( | ||
| <Suspense {...restSuspenseProps} fallback={typeof fallback === 'function' ? fallback(props) : fallback}> |
Overview
Closes #1799.
Suspense.withalready receives the wrapped component props when rendering the component, but itsfallbackoption could only be a static React node.This PR allows
fallbackto be a function inSuspense.with, so it can render fallback UI from the same props.AS-IS
The fallback could not use props passed to
Component.TO-BE
The callback form is only supported by
Suspense.with. The regular<Suspense />props are kept as-is.Changes
Suspense.with-specific fallback type<Suspense />@suspensive/reactTest plan
pnpm --filter @suspensive/react ci:test -- src/Suspense.spec.tsxpnpm --filter @suspensive/react ci:typepnpm --filter @suspensive/react ci:eslintpnpm exec oxfmt --check packages/react/src/Suspense.tsx packages/react/src/Suspense.spec.tsx .changeset/suspense-with-fallback-callback.mdPR Checklist