-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
refactor(Filters): optimize language and technology lists with useMemo #5008
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: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
📝 WalkthroughWalkthroughThe pull request adds Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5008 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 22 22
Lines 796 796
Branches 146 146
=========================================
Hits 796 796 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-5008--asyncapi-website.netlify.app/ |
Description
languageListandtechnologyListcomputationsuseMemohook import from React to prevent unnecessary re-computations on every renderlanguageListandtechnologyListinuseMemowith empty dependency arrays to ensure they are computed only once during component initializationProblem
The Filters component was performing expensive list computations (
tags.languagesandtags.technologies) on every render cycle, even when no relevant filter state had changed. This caused:Solution
The fix ensures that
languageListandtechnologyListare computed only once when the component mounts, rather than on every render. This is achieved by:useMemofrom ReactuseMemohooks with empty dependency arrays[]Since the
tagsobject is imported from a static JSON file and remains constant, these lists never need to be recomputed, making this optimization safe and effective.Test Results
PASS async/tests/components/tools/Filters.test.tsx
Filters Component Performance Optimization
✓ should import useMemo from react (3 ms)
✓ should use useMemo for languageList (1 ms)
✓ should use useMemo for technologyList (1 ms)
✓ should not compute lists directly from tags on every render (1 ms)
Test Suites: 1 passed, 1 total
Tests: 4 passed, 4 total
Snapshots: 0 total
Time: 5.536 s
Ran all test suites matching /tests/components/tools/Filters.test.tsx/i.
Changes Made
useMemofrom ReactlanguageListfrom direct assignment touseMemo(() => tags.languages as Language[], [])technologyListfrom direct assignment touseMemo(() => tags.technologies as Technology[], [])Testing
Related issue(s)
#4998
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.