-
Notifications
You must be signed in to change notification settings - Fork 523
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
Fix bug with recursion #9100
Fix bug with recursion #9100
Conversation
WalkthroughThe changes in the Changes
Assessment against linked issues
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
src/components/Facility/ConsultationDetails/index.tsxOops! Something went wrong! :( ESLint: 8.57.1 Error: Failed to load parser '@typescript-eslint/parser' declared in '.eslintrc.json': Cannot find module '@typescript-eslint/parser'
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Deploying care-fe with Cloudflare Pages
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
src/components/Facility/ConsultationDetails/index.tsx (2)
Line range hint
82-85
: Consider optimizing the tab selection logicThe current tab selection logic works but could be more efficient and clearer:
- let tab = undefined; - if (Object.keys(tabs).includes(props.tab.toUpperCase())) { - tab = props.tab.toUpperCase(); - } + const upperTab = props.tab.toUpperCase(); + const tab = tabs.hasOwnProperty(upperTab) ? upperTab : undefined;This change:
- Performs the uppercase conversion once
- Uses direct property check instead of array operations
- Makes the undefined assignment more explicit
Line range hint
196-206
: Optimize useEffect dependenciesThe useEffect dependency array includes unnecessary dependencies that could trigger extra re-renders:
useEffect(() => { const id = patientDataQuery.data?.id; if (!id) { return; } fetchData(id); triggerGoal("Patient Consultation Viewed", { facilityId: facilityId, consultationId: consultationId, userId: authUser.id, }); - }, [patientDataQuery.data?.id]); + }, [patientDataQuery.data?.id, fetchData]);Also update the fetchData useCallback:
const fetchData = useCallback( async (id: string) => { // Get shifting data const shiftRequestsQuery = await request(routes.listShiftRequests, { query: { patient: id }, }); if (shiftRequestsQuery.data?.results) { setActiveShiftingData(shiftRequestsQuery.data.results); } }, - [consultationId, patientData?.is_vaccinated], + [], );These changes:
- Remove unnecessary dependencies that could cause extra re-renders
- Add fetchData to useEffect dependencies as it's used inside
- Remove consultationId and patientData?.is_vaccinated from fetchData dependencies as they're not used
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/components/Facility/ConsultationDetails/index.tsx
(1 hunks)
🔇 Additional comments (1)
src/components/Facility/ConsultationDetails/index.tsx (1)
77-80
: LGTM! This change effectively fixes the infinite recursion issue.
The direct initialization of tabs
by merging defaultTabs
and pluginTabs
is a better approach than using state management. This eliminates unnecessary re-renders and prevents the infinite recursion issue that was causing lag in the application.
Let's verify that all tabs are properly initialized and accessible:
✅ Verification successful
Verified: Tabs initialization effectively resolves the infinite recursion issue with no further issues found.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify that all tab components are properly imported and used
# Look for any potential issues with tab imports or usage
# Check for proper tab component imports
echo "Checking tab component imports..."
rg -l "import.*ConsultationTab" src/
# Check for proper tab usage in the codebase
echo "Checking tab component usage..."
rg "tabs\[.*\]" src/
# Check for any TODO/FIXME comments related to tabs
echo "Checking for any known tab-related issues..."
rg -i "todo|fixme|hack|xxx|bug.*tab" src/
Length of output: 5136
CARE Run #3903
Run Properties:
|
Project |
CARE
|
Branch Review |
tabs-deps-bug
|
Run status |
Passed #3903
|
Run duration | 04m 52s |
Commit |
4a56fbe08f: Fix bug with recursion
|
Committer | Shivank Kacker |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
126
|
View all changes introduced in this branch ↗︎ |
@shivankacker @shivankacker Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit