Repository navigation
docs(react-component-runtime): useCommittedRefInto for refs declared above their value - #11368
Conversation
…above their value
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 42ee382 |
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
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
useCommittedRefIntoand callsuseCommittedRef.ts"two internal hooks", while INV3 ("goes only through Core's internaluseCommittedRef"), INV17 ("A latest-value ref usesuseCommittedRef"), the INV3 Verification row ("review accepts a latest-value ref only throughuseCommittedRef") and DEC-3 ("one shared internal hook") still allow only one, so describeuseCommittedRefIntoas 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.
…nd call shape; ToastRefSync sits before a children fragment
|
/approve-spec 53e2ba4 |
|
Decision: D-20261112-168 |
There was a problem hiding this comment.
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
mainnames 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.
Exact decision needed
None. This applies the owner's choice already recorded as
architecture:react-component-runtimeDEC-3 (one shared internal hook for latest-value refs) to a case found while adopting it.Existing authority searched
architecture:react-component-runtimeINV3, INV17 and DEC-3, and theuseCommittedRefOwning code entry.Decision
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.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
Scope
Records-only:
docs/architecture/react-component-runtime.md.Validation
pnpm check:knowledge: aligned.