-
Notifications
You must be signed in to change notification settings - Fork 668
feat: add loading and error component support to LingoProviderWrapper #1497
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the LingoProviderWrapper component by adding optional loadingComponent and errorComponent props to enable custom UI for loading and error states, resolving TODO comments in the codebase.
Key Changes:
- Added optional
loadingComponentanderrorComponentprops with comprehensive JSDoc documentation - Refactored state management from simple
D | nullto discriminated union withloading,loaded, anderrorstates - Added 5 new test cases covering loading, error, and state transition scenarios
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/react/src/client/provider.tsx | Added new props and state management logic for custom loading/error components |
| packages/react/src/client/provider.spec.tsx | Added comprehensive test coverage for new loading and error component functionality |
| .changeset/improved-loading-error-states.md | Added changeset documenting the new minor feature with usage examples |
Comments suppressed due to low confidence (1)
packages/react/src/client/provider.spec.tsx:167
- Unused variable rerender.
const { findByTestId, rerender } = render(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .fn() | ||
| .mockResolvedValue({ locale: "en", files: {} }); | ||
|
|
||
| const { findByTestId, rerender } = render( |
Copilot
AI
Nov 12, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rerender destructured from render() is assigned but never used in this test. This suggests either incomplete test implementation or unnecessary variable assignment.
Consider removing the unused rerender variable:
const { findByTestId } = render(| const { findByTestId, rerender } = render( | |
| const { findByTestId } = render( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved Old Problems
|
Again Check this Request |
This PR enhances the LingoProviderWrapper component in the React package by adding optional
loadingComponentanderrorComponentprops, enabling developers to provide custom UI for loading and error states instead of the defaultnullbehavior.This resolves two TODO comments in the codebase that identified the need for better loading and error state handling.
Changes
Core Implementation
loadingComponentprop: Optional component to display while the dictionary is loadingerrorComponentprop: Optional component to display when dictionary loading failsD | nullto discriminated union withloading,loaded, anderrorstatesErrorobjectTesting
Benefits
nullbehavior when props are not providedExample Usage
Checklist
pnpm new)pnpm turbo test)pnpm format)pnpm format:check)Code Quality
Test Results
Before/After
Before:
After: