Skip to content

docs(react-component-runtime): useCommittedRefInto for refs declared above their value - #11368

Merged
cixzhang merged 2 commits into
mainfrom
docs/committed-ref-into
Nov 12, 2026
Merged

cixzhang merged 2 commits into
mainfrom
docs/committed-ref-into

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Exact decision needed

None. This applies the owner's choice already recorded as architecture:react-component-runtime DEC-3 (one shared internal hook for latest-value refs) to a case found while adopting it.

Existing authority searched

  • architecture:react-component-runtime INV3, INV17 and DEC-3, and the useCommittedRef Owning code entry.

Decision

  • INV3, INV17, DEC-3, the INV3 verification row and the Owning code entry name the hook's second call shape: useCommittedRefInto(ref, value) writes a ref declared earlier, with the same insertion-Effect timing and the same read rule, for callbacks declared above the value they read; it writes the ref its caller hands over.
  • INV17's Toast exception becomes a placement note: ToastViewport renders ToastRefSync, which writes through useCommittedRefInto, before a fragment that holds its children, so a child's layout cleanup, an unmount's included, reads the committed list. DEC-3's ordering note points at it. The gap line "ToastViewport writes its toast list during render" stays until that change lands.

Rejected alternatives

None.

Claim scope and non-goals

INV3, INV17, DEC-3, the INV3 verification row and one Owning code entry. No code changes.

Evidence and implementation relationship

A callback declared above the value it reads cannot take a ref the hook returns later in the same component body, so the second shape writes a ref the caller declared first. The Toast change and the hook build follow in their own pull requests.

Writing rubric results

  • R1 narration: none.
  • R2 research or history in the record: none.
  • R5 pull request or issue references in the record: none.
  • R6 ruled open questions still listing options: none.
  • R7 project status in the record: none.

Scope

Records-only: docs/architecture/react-component-runtime.md.

Validation

  • pnpm check:knowledge: aligned.

@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 12, 2026 7:16am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 12, 2026
@astracat-bot

astracat-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 12, 2026, 7:33 AM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 42ee382

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 53e2ba4

Storybook · Sandbox · built from this PR's head

Package size: no published package changed; no new dependencies.

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Requesting changes: the new useCommittedRefInto shape is approved direction, but the record now contradicts itself in three places, each a short text fix.

  • The record adds useCommittedRefInto and calls useCommittedRef.ts "two internal hooks", while INV3 ("goes only through Core's internal useCommittedRef"), INV17 ("A latest-value ref uses useCommittedRef"), the INV3 Verification row ("review accepts a latest-value ref only through useCommittedRef") and DEC-3 ("one shared internal hook") still allow only one, so describe useCommittedRefInto as the one hook's second call shape and name it in those places, or amend DEC-3.
  • DEC-3's "(a descendant's layout-Effect cleanup runs earlier, the case INV17's Toast exception names)" now points at the exception this pull request removes, so point it at INV17's ToastRefSync placement note.
  • INV17's note says ToastRefSync renders "before its children, so a child's layout cleanup reads the committed list", but React commits a direct child's unmount before it visits ToastRefSync, so write "before a fragment that holds its children", as the Toast follow-up does.

Non-blocking: "Until they exist, sites keep the per-site Effect copies INV3's gap lists" in the Owning code entry states project status (rubric R7), and the rubric results have no R7 line.

Claims and files checked
  • No new decision is needed because this applies the existing one-hook decision: false, the record now names two hooks that decision does not cover (first finding).
  • INV3 and the owning-code entry add the hook's second call shape: false as written, the owning-code entry says two internal hooks (first finding).
  • The new shape writes a caller-declared ref with the same timing and read rule: verified in INV3 and the owning-code entry.
  • INV17's Toast exception becomes a placement note so a child's layout cleanup reads the committed list: the text is there; the ordering holds only with the children in their own fiber (third finding).
  • The gap line about the viewport writing its toast list during render stays: verified, and the viewport still writes its lists during render.
  • The scope is INV3, INV17 and one owning-code entry, records only, no code: verified, one file and three hunks.
  • The Toast change and the hook build follow in their own pull requests: verified, both are open.
  • Writing rubric: no narration, research, change references or ruled options left listed: verified in the added lines; the project-status item is not reported and one changed line states project status.
  • The knowledge check reported aligned: not re-run in this review.
  • docs/architecture/react-component-runtime.md: three findings and one non-blocking note above.

Automated review (maintainer link)

…nd call shape; ToastRefSync sits before a children fragment
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 12, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 53e2ba4

@cixzhang

Copy link
Copy Markdown
Contributor Author

Decision: D-20261112-168

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 12, 2026

@astracat-bot astracat-bot Bot 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.

Approved pending CI: this pull request is a draft, so CI has not run on this head yet; it runs once the pull request is marked ready for review.

The record now treats useCommittedRefInto(ref, value) as the second call shape of the one latest-value-ref hook everywhere DEC-3 applies, DEC-3's ordering note points at the ToastRefSync placement note, and that note keeps ToastViewport's children in their own fragment, so the three earlier findings are resolved.

  • Non-blocking: the writing rubric results list R1, R2, R5, R6 and R7 but skip R3 and R4; both pass on the changed lines, so adding those two lines completes the report.
Claims and files checked

Claims:

  • No new decision is needed because the change applies the recorded one-hook decision (DEC-3): verified. The record keeps one hook with two call shapes, and an engineering owner approved this exact head.
  • The search for existing authority covered INV3, INV17, DEC-3 and the hook's Owning code entry: verified. No other record on main names the hook or ToastRefSync.
  • INV3, INV17, DEC-3, the INV3 verification row and the Owning code entry all name the second call shape: verified (docs/architecture/react-component-runtime.md:136-140, :402-403, :584-586, :620, :548-554).
  • The second shape writes a ref the caller declared earlier, with the same timing and read rule, for callbacks declared above the value: verified (:137-140, :552-554).
  • INV17's Toast exception becomes a placement note with ToastRefSync before a fragment holding the children, unmount cleanups included: verified (:412-414; the exception is removed).
  • DEC-3's ordering note points at the placement note: verified (:596-597).
  • The gap line about ToastViewport's render-time write stays: verified (:414-415).
  • No rejected alternatives are added: verified; DEC-3 keeps its single existing Rejected: line (:601-602).
  • The scope is INV3, INV17, DEC-3, the verification row and one Owning code entry, with no code changes: verified; the only changed file is this record.
  • A callback declared above the value cannot take a ref the hook returns later in the body: verified; a dependency array that names that ref reads it before it is declared.
  • The Toast change and the hook build follow in their own pull requests: verified; both are open.
  • Rubric results report no narration, research, change references, ruled open questions or project status: verified on the changed lines; R3 and R4 are not reported (non-blocking note above).
  • The knowledge check passes: consistent; the change leaves the frontmatter, section headings, metadata block and record links that the check validates untouched.

Files:

  • docs/architecture/react-component-runtime.md: clear, with the non-blocking rubric note.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 12, 2026 07:54
@cixzhang
cixzhang merged commit 923b53a into main Nov 12, 2026
119 checks passed
@github-actions
github-actions Bot deleted the docs/committed-ref-into branch November 13, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — 53e2ba45 Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant