Skip to content

Backport React 19 use API - #32

Draft
christopher-buss wants to merge 5 commits into
Roblox:mainfrom
christopher-buss:backport-react-19-use
Draft

Backport React 19 use API#32
christopher-buss wants to merge 5 commits into
Roblox:mainfrom
christopher-buss:backport-react-19-use

Conversation

@christopher-buss

@christopher-buss christopher-buss commented Aug 31, 2026

Copy link
Copy Markdown

Summary

  • add stable React 19.2 use(Context) and cached Promise-compatible thenable reads
  • add generic reconciler thenable tracking, opaque suspension bridging, and retry/error behavior
  • support conditional and looped use calls without normal Hook ordering
  • add Debug Tools, shallow renderer, API docs, and a pinned upstream ledger

Compatibility boundary

This is the client cached-Promise API. Promises must be created and cached outside render, must settle normally, and expose andThen. React 19 server/RSC behavior, cache APIs, hydration, sibling prewarming, Actions, Promise-as-child, async components, and uncached component replay are excluded. Roblox Promise cancellation is unsupported because ordinary andThen listeners are not notified reliably.

React-Luau 17 has no React 19 SuspendedOnImmediate replay state machine. The opaque use exception is therefore converted before the existing unwind, Suspense capture, ping, and retry path; the cached Promise's instrumented status survives the retry.

Provenance

  • runtime and tests are pinned to React 19.2.0 at ae74234eae6ebd62f19190731278e20bc1c37d51
  • the swallowed try/catch warning follows ReactUse-test.js lines 534-568: exactly one warning containing the complete upstream text
  • React 17's console harness appends the component stack, so the translated toErrorDev assertion validates the stack instead of incorrectly requiring its absence; this adaptation is marked at the test site

The implementation and complete test/deviation classification are pinned in docs/backports/react-19-use.md.

Verification

Exact candidate: 706beab31c8dd20dc824e2254743da0bd87dfedc / tree f82a837524a8281e9c3af8c6e8450124b056bc77

  • preserved RED baseline at 28c57e5d4ab256956980c4fd3bf9f4d3c865630e: identity 1/1; ReactUse 13/14, with the expected warning text/count and component stack rejected only by the unsupported no-stack matcher option
  • hardened Studio debug.loadmodule rerun: identity 1/1 and complete ReactUse 14/14, including the try/catch warning regression
  • archive SHA-256: 1E1168AB3994E61A079852A148CCD70E4965C1C65374EF31E729337CBF92B59F
  • project SHA-256: 2302E858AE23831EBBE5FF0BFF2A351940F97CF6CEFE78C733940E835910457D
  • config SHA-256: A5800572BCEBADA709F02E0BA9C9E486EEC8919B40CBCDBFD7D5D71BF07E7C71
  • ReactUse Jest SHA-256: FAEEADA030DAA0BC6D41CBB8085E1CED9E3A1F3E13E7FA81FD2B6D03A5050E67
  • identity Jest SHA-256: D9984A6FE84B2A031B55DA85B5470C88EFAF73C4F7819C3434FA3159F8E84A59
  • full Selene 0.28.0: passed
  • full StyLua 0.18.1 check: passed
  • Luau bytecode compilation for every changed Lua file: passed
  • WorkLoop compiler register probe: R188, matching the known-good reconciler chunk
  • git diff and public privacy checks: passed
  • canonical bin/ci.sh: dependency installation, Roblox analysis, and DEV/release runtime stages remain unavailable locally because the pinned Roblox-internal Foreman sources and required CLI binaries are not accessible

Generated with Codex.

Co-authored-by: Codex <noreply@openai.com>
Load the thenable helper inside the two error paths so Studio debug.loadmodule can compile the near-limit WorkLoop chunk.

Co-authored-by: Codex <noreply@openai.com>
Document the React 17 replay and thenable-tracking divergences, correct pinned source ranges, and make the test ledger match the actual port.

Port the fulfilled-thenable regression and preserve observable scheduler yield order across the translated use cases.

Co-authored-by: Codex <noreply@openai.com>
Match the upstream warning count and text contract while allowing React 17's console harness to append the component stack.

Co-authored-by: Codex <noreply@openai.com>
Use the upstream development wrapper and production array shapes without an unnecessary React-Luau deviation.

Co-authored-by: Codex <noreply@openai.com>
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.

1 participant