fix: memoize context values to prevent infinite re-renders#69
Open
mvanhorn wants to merge 1 commit intoelevenlabs:mainfrom
Open
fix: memoize context values to prevent infinite re-renders#69mvanhorn wants to merge 1 commit intoelevenlabs:mainfrom
mvanhorn wants to merge 1 commit intoelevenlabs:mainfrom
Conversation
ActiveThemeProvider and BlockViewerProvider were creating new object references on every render, causing all context consumers to re-render infinitely. Wrap context values in useMemo to maintain referential equality across renders. Fixes elevenlabs#59 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
@mvanhorn is attempting to deploy a commit to the ElevenLabs Team on Vercel. A member of the Team first needs to authorize it. |
kraenhansen
approved these changes
Mar 20, 2026
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.
Summary
ActiveThemeProvidercontext value withuseMemoto prevent new object references on every renderBlockViewerProvidercontext value withuseMemofor the same reasonWhy this matters
#59 reports infinite re-renders on the home page. The reporter traced it via React Profiler to a Context Provider creating new object references per render - this is the classic unmemoized context value pattern.
ActiveThemeProviderwraps the entire app in the root layout (app/layout.tsx), so every render of that provider triggers a re-render of every consumer in the tree. Wrapping the value inuseMemomaintains referential equality and breaks the render loop.Changes
apps/www/components/active-theme.tsx- wrap{ activeTheme, setActiveTheme }inuseMemoapps/www/components/block-viewer.tsx- wrap context value object inReact.useMemoTesting
pnpm run typecheckpassesmain(unrelated/radiopage data collection error)Fixes #59
This contribution was developed with AI assistance (Claude Code).