docs(bridge): clarify createLazyComponent error handling - #4945
Conversation
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f15fb1891f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| The error component rendered when remote module loading or data fetching fails. | ||
|
|
||
| It does not catch errors thrown while React renders the loaded component or its descendants. To handle client-side render errors, wrap the lazy component in an Error Boundary in the host application. Server-rendering errors must be handled by the server rendering pipeline because React Error Boundaries do not catch them. |
There was a problem hiding this comment.
Include lazy-resolution failures in Error Boundary guidance
When the configured export is missing or is not a function—or when the loader's second invocation rejects—the error is thrown from the React.lazy factory (packages/bridge/bridge-react/src/lazy/createLazyComponent.tsx:286-338), outside the fallback handling around getData. Thus fallback does not cover every remote-module loading/resolution failure as stated here, while the following guidance only mentions errors thrown by the loaded component or its descendants. Document that these lazy-resolution errors also require a host Error Boundary so users do not rely on fallback for a misconfigured export or second-load failure.
Useful? React with 👍 / 👎.
Description
Clarify the documented error-handling behavior of
createLazyComponent.The previous documentation stated that the API included an Error Boundary and that
fallbackhandled rendering failures. However, the implementation only usesfallbackfor remote module loading and data-fetch failures. Errors thrown while rendering the loaded component or its descendants must be handled separately.This PR:
createLazyComponentincludes an Error Boundary;fallback;This is a documentation-only change. It does not change runtime behavior or the public API.
Validation:
pnpm exec prettier --check apps/website-new/docs/en/guide/bridge/react/load-component.mdx apps/website-new/docs/zh/guide/bridge/react/load-component.mdx apps/website-new/docs/pt-BR/guide/bridge/react/load-component.mdxRelated Issue
N/A
Types of changes
Checklist