Repository navigation
docs: document JSX values evaluating after the building call - #1369
Merged
Merged
Conversation
Compiler-authored JSX values defer their non-literal props and children to the represented render scope (#361). The divergence doc framed this around providers and boundaries, but it also covers host-only markup, so a value that exists only while the building call runs is gone at render time. A Lexical DecoratorNode whose decorate() returns <span>{this.getLabel()}</span> throws in $getState because the label is read after Lexical's editor state is no longer active. Document the consequence with the Lexical example and the fixes: read the value into a local, use createElement, or read from a component. Pin all three forms in scoped-jsx-values for TSRX and TSX on client and server. Co-Authored-By: Claude Opus 5.5 <[email protected]>
trueadm
marked this pull request as ready for review
September 28, 2026 15:51
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
Documents that a compiler-authored JSX value's non-literal props and children can run after the call that built it has returned, and pins that behavior with tests. No runtime or compiler change.
A test port found that a Lexical
DecoratorNodewhosedecorate()returns<span>{this.getLabel()}</span>throws in$getState. Lexical callsdecorate()while it reconciles an update with editor state active, and React evaluatesthis.getLabel()right there. Octane defers the child to render time (the stack runs throughdescNeedsBlocks). By then no editor state is active.That deferral is intentional. #361 made JSX values resolve in their represented render scope, and the existing
SharedDescriptorProviderstests pin it for host-only markup: one stored<span>{…}</span>rendered under two providers shows each provider's own value. The divergence doc framed this around providers and boundaries, though. It didn't say that plain markup is deferred too, or that values valid only during the building call are gone by render time.Changes
docs/differences-from-react.md: new subsection "Values that exist only during the building call" under "JSX values follow the represented render scope". It covers the Lexicaldecorate()example and three fixes:createElement(...), which evaluates its arguments immediately;editor.read(...).packages/octane/tests/scoped-jsx-values.test.tsand_fixtures/scoped-jsx-values.tsx: aScopedDecoratorfixture builds JSX inside a synchronous "active scope" and renders it in a different one. The inline form reads the render scope; the local andcreateElementforms read the build scope. These run for TSRX and TSX, client and server (24 cases across the dev and prod projects).Validation
pnpm format:checkpnpm typecheck: not run. It doesn't coverpackages/octane/tests(excluded inpackages/octane/tsconfig.json).pnpm typecheck:fileson the two test files shows three errors, and HEAD has the same three.pnpm test: not run in full. CI covers it.npx vitest run packages/octane/tests/scoped-jsx-values.test.tspasses (669 tests, bothoctaneandoctane-prodprojects).jsxValueRootNeedsRenderScope/jsxValueChildrenNeedRenderScopereturning false), all 8 inline cases fail and the local andcreateElementcases still pass.pnpm react-parity:validate(includes the scan of this doc for misleading claims) passes. A local fullpnpm react-parity:checkexited 1 on a testing-librarywaitFortimer error in an upstream React test run. That run doesn't touch these files, but I didn't rerun it at the base to confirm.Risk / follow-ups
functionthat returns JSX goes throughisReturnJsxFunction, which evaluates its holes immediately. The same JSX from an arrow or a method is deferred. So a host-only element fromfunction hostDecl()rendered inside<Ctx value="inner">readsouter, and the arrow version readsinner, which contradicts theSharedDescriptorProviderscontract. The new doc text says expressions "can run after", which stays true whichever way that is resolved.Provenance
agent-authored)🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Note
Low Risk
Documentation and test coverage only; no production runtime or compiler behavior changes.
Overview
Documents and regression-tests that compiler-authored JSX stored in variables or props can evaluate non-literal children and props at render time, not while the building call (e.g.
decorate()) is still on the stack—unlike React, which runs those expressions immediately.Adds
docs/differences-from-react.mdsubsection Values that exist only during the building call: plain host markup is deferred too; Lexical-styleDecoratorNode.decorate()pitfalls; fixes (read into locals before JSX,createElementfor immediate args, or defer reads to a child witheditor.read(...)).Adds
ScopedDecoratorfixtures and client + server tests for inline JSX (label from render scope), locals /createElement(label from build scope)—no compiler or runtime changes.Reviewed by Cursor Bugbot for commit 2d50735. Bugbot is set up for automated code reviews on this repo. Configure here.