Skip to content

Stop updating other components while rendering - #5958

Merged
Eugene (OEvgeny) merged 6 commits into
mainfrom
OEvgeny/fix-render-phase-updates
Oct 22, 2026
Merged

Eugene (OEvgeny) merged 6 commits into
mainfrom
OEvgeny/fix-render-phase-updates

Conversation

@OEvgeny

@OEvgeny Eugene (OEvgeny) commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

React development builds log "Cannot update a component while rendering a different component" for toasts, typing, the "New messages" button and part grouping (the test harness ignored it with a TODO: [P0]).

Changelog Entry

Fixed

  • Fixed state updates while rendering that React development builds logged as "Cannot update a component while rendering a different component", from the toaster, the typing indicator, the "New messages" button, and part grouping, in PR #5958, by @OEvgeny

Description

Web Chat updated the live region, read/acknowledged state and part grouping from useMemo while rendering other components. They now update in layout effects, before paint as before, and the harness fails on the warning.

Design

  • Layout effects, not passive effects: announcements stay in the frame of the visual change.
  • Part grouping keeps its map in a ref: the state was never read, and an effect would be a render late.

Specific Changes

  • useLiveRegion: layout effect, once per deps change
  • LiveRegionTranscript: typing uses useLiveRegion
  • ScrollToEndButton, InternalTranscriptScrollable: mark read/acknowledged in layout effects
  • ActivityLogicalGroupingComposer: ref, no unread state
  • createGraphFromStore, GraphProvider: add rehydrated activities on creation, sync in a layout effect
  • done.js, hideKnownError.js, 2 tests: stop ignoring it
  • toast/noUpdateWhileRendering.html: snapshot 1, toast announced
  • scrollToEndButton.noUpdateWhileRendering.html: snapshot 1, "Message 6." focused
  • typingIndicator.liveRegion.noUpdateWhileRendering.html: snapshot 1, "Bot is typing." announced
  • I have added tests and executed them locally
  • I have added .changelog/<PR#>-<slug>.md
  • I have updated documentation

Review Checklist

This section is for contributors to review your work.

  • Accessibility reviewed (tab order, content readability, alt text, color contrast)
  • Browser and platform compatibilities reviewed
  • CSS styles reviewed (minimal rules, no z-index)
  • Documents reviewed (docs, samples, live demo)
  • Internationalization reviewed (strings, unit formatting)
  • package.json and package-lock.json reviewed
  • Security reviewed (no data URIs, check for nonce leak)
  • Tests reviewed (coverage, legitimacy)

Eugene Olonov added 5 commits October 22, 2026 04:44
…edged state

useLiveRegion and the typing indicator queued live region nodes in useMemo, the
"New messages" button marked activities as read and the transcript marked them as
acknowledged in useMemo. React development builds log "Cannot update a component
while rendering a different component" for each. Move the updates into layout
effects (still before paint) and queue a live region node once per deps change,
also in Strict Mode.
Part grouping registers itself while rendering and its activities read their group
while rendering. The map was also kept in a state that was never read, so the
registration updated <ActivityLogicalGroupingComposer> while rendering.
…ut effects re-render

A rehydrated store has activities before the graph is created, but the graph only added them on the next dispatch, and <GraphProvider> synchronized in a passive effect.
Queuing the rehydrated notification to the live region in a layout effect re-renders the transcript (useActivities) after passive effects but before the graph state update, and the development assertion found 0 activities in the graph and 1 in Redux.

- createGraphFromStore: add the store's activities when the graph is created
- GraphProvider: subscribe and synchronize in a layout effect, so the graph state is updated in the same render as other layout effect updates
@OEvgeny
Eugene (OEvgeny) marked this pull request as ready for review October 22, 2026 16:02
Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Comment thread packages/component/src/Transcript/LiveRegionTranscript.tsx
@OEvgeny
Eugene (OEvgeny) merged commit a19b06e into main Oct 22, 2026
33 checks passed
@OEvgeny
Eugene (OEvgeny) deleted the OEvgeny/fix-render-phase-updates branch October 22, 2026 22:12
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.

3 participants