RFC: useContextSelector() amend with Option D (Relay pattern)#36001
Open
layershifter wants to merge 5 commits intomasterfrom
Open
RFC: useContextSelector() amend with Option D (Relay pattern)#36001layershifter wants to merge 5 commits intomasterfrom
layershifter wants to merge 5 commits intomasterfrom
Conversation
The original RFC considered Options A, B, C and selected A (do nothing). Option D was not considered at the time — it emerged from a conversation with the React team after the decision was made. This addendum: - Documents the root cause of the original RFC's "Glitchy Behavior" note: fiber.lanes pollution on the bound-at-mount fiber in dispatchSetStateInternal's eager-bailout check. - Specifies Option D: allow Level 1 tearing, heal in effect via epoch/selector check. Matches Relay's useFragmentInternal pattern. - Compares Option D to Option A across glitch, tearing, concurrent correctness, lint, and API dimensions. - Re-establishes why Options B and C remain inadequate, with new empirical evidence against C (uncommitted-transition value leaks to urgent sibling renders under concurrent mode). - Includes measurements from an investigation probe. Does not modify the original decision record. The addendum is clearly dated and labeled so the history of the prior decision is preserved. Accompanying implementation PR: layershifter/fix-context-selector-bailout.
📊 Bundle size report✅ No changes found |
|
Pull request demo site: URL |
…nk public repro - Drop references to docs/phase-3-root-cause.md, docs/phase-5-comparison.md, and repro/tests/list-probe-cycling.json (private investigation workspace). - Replace with link to public reproduction repo: https://github.com/layershifter/context-selector-bailout-repro - Pin Relay implementation references to commit e3c9d1b5661fb6f58e4d58f81cd930e09a47a89a so links don't move as main progresses.
b0d9e7a to
487dd27
Compare
Hotell
approved these changes
Apr 23, 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
The original RFC considered Options A, B, C and selected A ("do nothing"). Option D was not considered at the time - it emerged from a conversation with the React team after the decision was made. Option D strictly improves on Option A for the "Glitchy Behavior" case without regressing anything else.
What's in the addendum
fiber.lanespollution issue in React'sdispatchSetStateInternaleager-bailout check - the bound-at-mount fiber becomes the stale alternate after the first listener-driven commit and its lanes never get cleared, permanently failing theNoLanesprecondition.react-dom.development.jsthat logsfiber.lanes/alternate.lanesat the check site. First dispatch:fiber=0 alt=0 eager=TRUE. All subsequent dispatches on that fiber:fiber=1 alt=0 eager=FALSE.valueRef.currentduring render (likeuseSyncExternalStore.getSnapshot), no[value, selected]state tuple, nosetState(prev => prev)bailout trick. Listener comparesselector(newValue)against a layout-effect-latchedlastReturnedRef.currentand force-updates only when the slice actually differs. Matches Relay'suseFragmentInternal_CURRENT.jspattern.Accompanying PR
#36002 — implementation of Option D in
@fluentui/react-context-selector.Out of scope