Skip to content

Conversation

@sanks011
Copy link

@sanks011 sanks011 commented Aug 31, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR implements React performance optimizations across multiple search components in the cohort builder application to reduce unnecessary re-renders and improve memory usage.

Changes Made:

  • Add useMemo for static arrays in SearchByDemographics (genders, livingStatuses)
  • Add useMemo for static arrays in SearchByConcepts (observationOptions, whichObservation)
  • Add useMemo for methods array in SearchByLocation
  • Add useCallback for event handlers across all search components
  • Add .vscode to gitignore for better IDE integration
  • Reduces unnecessary re-renders and improves memory usage
  • Maintains full functionality - all tests passing (26/26 tests)

Performance Benefits:

  • Reduced component re-renders through memoization of static data
  • Better memory usage by preventing recreation of objects/functions
  • Improved user experience during frequent interactions
  • Follows React best practices for component optimization

Components Optimized:

  • SearchByDemographics - Static arrays and event handlers memoized
  • SearchByConcepts - Observation options and functions optimized
  • SearchByLocation - Methods array and handlers optimized
  • SearchByEnrollments - Event handlers optimized

Screenshots

Related Issue

Other

All existing functionality is preserved. No breaking changes. TypeScript and ESLint compliant. Added .vscode to gitignore for better development experience.

sanks011 and others added 3 commits August 31, 2025 20:00
- Add useMemo for static arrays in SearchByDemographics (genders, livingStatuses)
- Add useMemo for static arrays in SearchByConcepts (observationOptions, whichObservation)
- Add useMemo for methods array in SearchByLocation
- Add useCallback for event handlers across all search components
- Reduces unnecessary re-renders and improves memory usage
- Maintains full functionality - all tests passing
- Add useMemo for static arrays in SearchByDemographics (genders, livingStatuses)
- Add useMemo for static arrays in SearchByConcepts (observationOptions, whichObservation)
- Add useMemo for methods array in SearchByLocation
- Add useCallback for event handlers across all search components
- Add .vscode to gitignore for better IDE integration
- Reduces unnecessary re-renders and improves memory usage
- Maintains full functionality - all tests passing
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.

1 participant