Add useMemo/useCallback to context providers, fix broken react depend… - #529
Merged
YOGESH-08 merged 2 commits intoAug 16, 2026
Merged
Conversation
…ency Fixes CodeChefVIT#471. Memoizes the Provider value objects in courseContext, filterContext, Card's PaperProvider usage, and carousel.tsx's CarouselContext, which were being rebuilt on every render and causing unnecessary re-renders in consumers. Also fixes package.json, where react was pinned via a broken link: path instead of a real version, which broke local installs.
YOGESH-08
reviewed
Aug 15, 2026
| paginatedPapers, | ||
| totalPages, | ||
| }; | ||
| const value: FilterContextType = useMemo( |
Collaborator
There was a problem hiding this comment.
Splitting into 2 Contexts
Separate state (frequently changing) from actions (stable functions)
Addresses review feedback on the value memoization: separates frequently-changing state (papers, filters, pagination) from stable action functions into two contexts, so a future consumer that only needs actions won't re-render on unrelated state changes. useFilters() still works exactly as before for existing consumers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #471
Changes Made
Memoized Provider
valueobjects in:courseContext.tsxfilterContext.tsxCard.tsx(PaperProvider)carousel.tsx(CarouselContext)Prevented unnecessary re-renders of context consumers when the Provider values have not changed.
Fixed the
reactdependency inpackage.json, restoring it to^18.3.1to matchreact-dom.Verification
tsc --noEmit✅pnpm build✅pnpm lint✅All checks pass successfully.