Skip to content

perf(components): memoize the slot context value - #3588

Merged
mfal merged 1 commit into
nextfrom
perf/memoize-slot-context
Oct 27, 2026
Merged

mfal merged 1 commit into
nextfrom
perf/memoize-slot-context

Conversation

@mfal

@mfal mfal commented Oct 27, 2026

Copy link
Copy Markdown
Member

SlotContextProvider built { ...parentContext, [component]: slot } on every
render. Every slotted component therefore handed its slot context consumers a
new value on each render and re-rendered them, e.g. the buttons of a
confirmation modal, although the slot had not changed.

The value is now memoized on parentContext, component and slot.

The new browser test re-renders a slotted component with a changed unrelated
prop and asserts that a memoized useSlotContext() consumer below it does not
re-render; it fails without the fix. Changing the slot still re-renders the
consumer.

Independent of #3579, which fixes the same pattern in the props context.

🤖 Generated with Claude Code

SlotContextProvider built a new context object on every render, so every
slotted component re-rendered all slot context consumers below it, even
when the slot was unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mfal mfal self-assigned this Oct 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Preview Deployment

Preview environments are ready:

Type URL
docs pr-3588.docs.review.flow-components.de
storybook pr-3588.storybook.review.flow-components.de

Images:

  • docs: ghcr.io/mittwald/flow/docs:pr-3588
  • storybook: ghcr.io/mittwald/flow/storybook:pr-3588

@mfal
mfal marked this pull request as ready for review October 27, 2026 13:49
@mfal
mfal requested a review from a team October 27, 2026 13:49
@mfal
mfal merged commit fd9a846 into next Oct 27, 2026
24 checks passed
@mfal
mfal deleted the perf/memoize-slot-context branch October 27, 2026 14:05
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.

2 participants