docs: fix render function/helper API documentation#3088
Conversation
Address documentation gaps and inaccuracies across render function, view helper, and component registration docs. Key changes: - Mark redirectLocation/routeError as legacy (React Router v3/v4) with modern alternatives documented - Add component type x Ruby helper compatibility matrix - Document react_component_hash silently forcing prerender: true - Document stream_react_component forcing prerender + immediate_hydration - Document Navigate component SSR behavior (no-op, client-only redirect) - Document async render function + ExecJS silent failure - Document isServerRenderResult broad detection (error key) - Document JSX-returning render function deprecation status - Document clientProps symbol/string key merge edge cases - Add registerServerComponent per-bundle signature gotcha in Pro docs - Update register() JSDoc with detection logic and return types Closes #2911 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughDocumentation-only revisions clarifying component registration detection (parameter-count and Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/oss/core-concepts/render-functions.md`:
- Line 252: The compatibility matrix entry claiming "Promise (any)" for
react_component_hash is inaccurate; update the table cell and related text to
require a Promise that resolves to the server-render-hash shape (e.g., an object
matching { renderedHtml: { componentHtml, ... } } after render-function
processing) rather than "any", and clarify that runtime errors may occur if the
resolved value doesn't match that shape; reference react_component_hash and the
"Render function → Promise" column when making this wording change.
In `@docs/pro/react-server-components/inside-client-components.md`:
- Line 72: Remove the empty blank line inside the warning blockquote in
inside-client-components.md (the quoted warning block that triggers MD028) so
the blockquote has no blank lines between ">" lines; simply delete the stray
empty quoted line to satisfy the no-blanks-blockquote rule and re-run
markdownlint to confirm the MD028 violation is resolved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2bab0dc7-9cbb-4f01-8ee3-a3eeeb6beb59
📒 Files selected for processing (6)
docs/oss/api-reference/javascript-api.mddocs/oss/api-reference/view-helpers-api.mddocs/oss/building-features/react-router.mddocs/oss/core-concepts/render-functions.mddocs/oss/getting-started/using-react-on-rails.mddocs/pro/react-server-components/inside-client-components.md
Review SummaryGood overall: most documented behaviors are verified against source (component detection by parameter count, Two factual inaccuracies need fixing before merge: 1.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0589c718cf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Greptile SummaryThis PR comprehensively improves the render-function and view-helper API documentation by adding legacy markers for Confidence Score: 5/5Safe to merge — documentation-only changes with one minor matrix inaccuracy that doesn't affect runtime behavior All behavioral claims were verified against the source code. The single P2 finding (compatibility matrix overstating Promise support for react_component_hash) is a documentation nuance that doesn't cause silent failures — developers would get a visible runtime error. No executable code changed. docs/oss/core-concepts/render-functions.md — the compatibility matrix row for Promise types
|
| Filename | Overview |
|---|---|
| docs/oss/core-concepts/render-functions.md | Major overhaul adding legacy markers, a new compatibility matrix, and Important Rendering Behavior notes; the "Promise (any)" matrix row overstates what works with react_component_hash |
| docs/oss/api-reference/view-helpers-api.md | Accurate clarifications: prerender:true forcing for react_component_hash, stream_react_component constraints, and legacy deprecation note; all verified against source code |
| docs/oss/api-reference/javascript-api.md | register() JSDoc rewritten with accurate parameter-count detection logic (verified against isRenderFunction.ts) and complete return type inventory |
| docs/oss/building-features/react-router.md | New Navigate SSR behavior section is accurate: renders null, useEffect skipped during SSR, and React Router v6 does log a no-op warning in StaticRouter context |
| docs/oss/getting-started/using-react-on-rails.md | Example corrected to use title/metaTags instead of redirectLocation/error, legacy deprecation note added; changes are accurate |
| docs/pro/react-server-components/inside-client-components.md | registerServerComponent signature callout clearly documents the intentional server-vs-client bundle API difference; valuable addition |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Render Function return value] --> B{isServerRenderHash?}
B -- "has renderedHtml / redirectLocation / routeError / error key" --> C[Server Render Hash path]
B -- "no match" --> D{isPromise?}
D -- yes --> E[Promise path\nPro Node renderer only]
D -- no --> F[React Component path\ncreateReactOutput]
C --> G{renderedHtml type?}
G -- "string" --> H[react_component ✅]
G -- "ReactElement" --> I[react_component prerender ✅]
G -- "{ componentHtml, ...keys }" --> J[react_component_hash ✅]
E --> K{resolves to?}
K -- "string / React component" --> H
K -- "{ componentHtml, ...keys }" --> J
K -- "Promise of React component" --> H
F --> L[react_component ✅\nstream_react_component ✅]
Reviews (1): Last reviewed commit: "docs: fix render function/helper API doc..." | Re-trigger Greptile
…nd Promise matrix - Fix stream_react_component docs: immediate_hydration is a removed option (warns and deletes), not forced to true - Fix registerServerComponent client signature: accepts variadic strings only, no options object - Narrow "Promise (any)" to "Promise (compatible return shape)" for react_component_hash — only hash-shaped promises are valid Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Review feedback addressed (ed159a9)Three factual inaccuracies fixed, verified against source code:
Declined: Streaming Promise support claim (item 4) — needs full pipeline verification, deferred to follow-up. All 8 review threads resolved with replies. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/oss/core-concepts/render-functions.md (1)
138-139: Consider varying sentence structure for improved readability.The three consecutive sentences beginning with "For" create a repetitive pattern that slightly reduces readability.
✍️ Suggested rewording
> **Modern alternatives:** > -> - For redirects during SSR, handle them in your Rails controller (e.g., check auth before rendering). +> - To handle redirects during SSR, check conditions in your Rails controller (e.g., auth checks before rendering). > - For client-side redirects, use `<Navigate to="/path" />` (note: this is a [no-op during SSR](../building-features/react-router.md#navigate-component-ssr-behavior)). > - For route errors, use React Router's `errorElement` or an `ErrorBoundary`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/oss/core-concepts/render-functions.md` around lines 138 - 139, The three consecutive sentences that start with "For" are repetitive; rephrase the sentence that currently reads "For route errors, use React Router's `errorElement` or an `ErrorBoundary`." to vary sentence structure — for example: "Handle route errors by using React Router's `errorElement` or an `ErrorBoundary`." — and update the surrounding two "For ..." sentences similarly to avoid the repeated opener while keeping references to `errorElement` and `ErrorBoundary`.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/oss/core-concepts/render-functions.md`:
- Around line 138-139: The three consecutive sentences that start with "For" are
repetitive; rephrase the sentence that currently reads "For route errors, use
React Router's `errorElement` or an `ErrorBoundary`." to vary sentence structure
— for example: "Handle route errors by using React Router's `errorElement` or an
`ErrorBoundary`." — and update the surrounding two "For ..." sentences similarly
to avoid the repeated opener while keeping references to `errorElement` and
`ErrorBoundary`.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4df9a7b3-c921-45ca-ad93-f53437e51c72
📒 Files selected for processing (3)
docs/oss/api-reference/view-helpers-api.mddocs/oss/core-concepts/render-functions.mddocs/pro/react-server-components/inside-client-components.md
✅ Files skipped from review due to trivial changes (1)
- docs/pro/react-server-components/inside-client-components.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/oss/api-reference/view-helpers-api.md
Review: docs/fix render function/helper API documentationOverall this is a high-quality documentation PR — the compatibility matrix, 1. "Legacy (React Router v3/v4)" framing for
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed159a9f31
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
… footnote, and legacy framing Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Review feedback addressed (3c427ba)I (Claude Code) addressed all 6 remaining review comments: Accuracy fixes:
Framing & detail improvements: |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/pro/react-server-components/create-without-ssr.md (1)
362-363:⚠️ Potential issue | 🟡 MinorRemove or update outdated paragraph referencing
rscPayloadGenerationUrlPathas an option.This paragraph refers to
rscPayloadGenerationUrlPathas an "option" and promises to explain it later, but:
- The updated API (line 346) no longer accepts an options object—it only accepts string component names.
- Based on the implementation,
rscPayloadGenerationUrlPathcomes from therailsContextobject (injected by Rails via configuration), not fromregisterServerComponent.- There is no further explanation of this "option" later in the document.
This text appears to be a holdover from the old API and should be removed or rewritten to clarify that
rscPayloadGenerationUrlPathis configured via Rails (e.g., through the initializer or routes) and automatically provided to client components through therailsContext.📝 Suggested fix: remove outdated paragraph
-The `rscPayloadGenerationUrlPath` option will be explained in detail later in this document. For now, just know that it specifies the base URL path for React Server Component requests. -🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/pro/react-server-components/create-without-ssr.md` around lines 362 - 363, Remove the outdated paragraph that calls `rscPayloadGenerationUrlPath` an "option" and promises later explanation; instead update the text to state that `rscPayloadGenerationUrlPath` is provided via the Rails-injected `railsContext` (configured in Rails initializers/routes) and is not an argument to `registerServerComponent` (which now only accepts string component names), or simply delete the paragraph if no replacement wording is desired.
🧹 Nitpick comments (1)
docs/oss/core-concepts/render-functions.md (1)
231-231: Tighten compound modifier hyphenation for readability.“Client-side only rendering” reads better as “client-side-only rendering” in this bullet.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/oss/core-concepts/render-functions.md` at line 231, The bullet text "Client-side only rendering (always forces server rendering)" should be updated to use tightened compound hyphenation—change the phrase to "client-side-only rendering (always forces server rendering)" to improve readability; locate the string in docs/oss/core-concepts/render-functions.md and replace the existing phrase accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@docs/pro/react-server-components/create-without-ssr.md`:
- Around line 362-363: Remove the outdated paragraph that calls
`rscPayloadGenerationUrlPath` an "option" and promises later explanation;
instead update the text to state that `rscPayloadGenerationUrlPath` is provided
via the Rails-injected `railsContext` (configured in Rails initializers/routes)
and is not an argument to `registerServerComponent` (which now only accepts
string component names), or simply delete the paragraph if no replacement
wording is desired.
---
Nitpick comments:
In `@docs/oss/core-concepts/render-functions.md`:
- Line 231: The bullet text "Client-side only rendering (always forces server
rendering)" should be updated to use tightened compound hyphenation—change the
phrase to "client-side-only rendering (always forces server rendering)" to
improve readability; locate the string in
docs/oss/core-concepts/render-functions.md and replace the existing phrase
accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 059e6268-9954-4a5d-bb75-a52482725a10
📒 Files selected for processing (4)
docs/oss/api-reference/javascript-api.mddocs/oss/building-features/react-router.mddocs/oss/core-concepts/render-functions.mddocs/pro/react-server-components/create-without-ssr.md
✅ Files skipped from review due to trivial changes (2)
- docs/oss/building-features/react-router.md
- docs/oss/api-reference/javascript-api.md
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c427baca2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review: docs: fix render function/helper API documentationOverall this is a high-quality, well-researched documentation PR. I verified all the behavioral claims (parameter-count detection, One inaccuracy foundCompatibility matrix footnote ( The note claims ❌ combinations "silently produce incorrect output," giving Everything else looks correct
The |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Review feedback addressed (2bef3c5)I (Claude Code) addressed 2 remaining review comments, both verified against source:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2bef3c5849
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Review: docs: fix render function/helper API documentationOverall this is a high-quality documentation PR that fills genuine gaps. I verified all the core technical claims against the source code — component detection logic, A couple of issues worth addressing before merge (see inline comments):
|
…_hydration note - Correct the `error` key description: it triggers server-render-hash detection only, not exception behavior (only `routeError` sets the error flag) - Distinguish error types in compatibility matrix footnote: Ruby-side ReactOnRails::Error vs JS-side ReactOnRails::PrerenderError vs embedded HTML - Add `immediate_hydration` deprecation note to react_component_hash docs Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Review feedback addressed (489d433)All 4 unresolved review threads have been addressed and resolved:
|
There was a problem hiding this comment.
🧹 Nitpick comments (3)
docs/oss/core-concepts/render-functions.md (3)
166-167: Consider clarifying theerrorkey gotcha.The broadened server-render-hash detection is accurate, but the note "returning an object with an
errorkey from a render function triggers server-render-hash processing" could surprise developers who useerroras a regular data field in their component props. The current wording is clear about the detection logic, but you might consider adding a brief example or callout that this applies even whenerroris intended as component data (not a framework-level field).However, since the text already states "This may be surprising if you intended
erroras a regular data field," the current wording is likely sufficient.💡 Optional enhancement: add a concrete example
If you want to make the gotcha more concrete, you could add:
5. **Server render result detection is broad** - React on Rails treats any object containing a `renderedHtml`, `redirectLocation`, `routeError`, or `error` key as a server render result (not a React component). This means returning an object with an `error` key from a render function triggers server-render-hash processing rather than being treated as a React component. Note that `error` is only used for detection — it is not itself treated as an exception descriptor. Only `routeError` sets the error flag during processing. This may be surprising if you intended `error` as a regular data field. + + ```jsx + // ⚠️ This triggers server-render-hash processing, not component rendering + const MyComponent = (props) => ({ error: 'validation failed', data: null }); + ```🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/oss/core-concepts/render-functions.md` around lines 166 - 167, Clarify the "error" key gotcha by explicitly noting that any returned object containing the key "error" (not just "routeError") will be treated as a server-render-hash result and therefore won't be rendered as a React component; update the paragraph to add one short concrete example reference (e.g., mention a component like MyComponent that returns { error: 'validation failed' } as props) and/or a one-sentence callout advising authors to avoid using a top-level "error" field in render-returned objects (or rename it) to prevent accidental server-render-hash handling — reference the terms "error", "routeError", and "server-render-hash" so readers can map this guidance to the existing detection logic.
136-138: Optional: vary sentence openings for style.Three consecutive bullet points start with "For" (lines 136-138). While grammatically correct, varying the sentence structure could improve readability:
> **Modern alternatives:** > -> - For redirects during SSR, handle them in your Rails controller (e.g., check auth before rendering). -> - For client-side redirects, use `<Navigate to="/path" />` (note: this is a [no-op during SSR](../building-features/react-router.md#navigate-component-ssr-behavior)). -> - For route errors, use React Router's `errorElement` or an `ErrorBoundary`. + - Handle redirects during SSR in your Rails controller (e.g., check auth before rendering). + - For client-side redirects, use `<Navigate to="/path" />` (note: this is a [no-op during SSR](../building-features/react-router.md#navigate-component-ssr-behavior)). + - To handle route errors, use React Router's `errorElement` or an `ErrorBoundary`.However, the current wording is clear and parallel, so this is purely stylistic.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/oss/core-concepts/render-functions.md` around lines 136 - 138, The three bullets all begin with "For" which is repetitive; reword them to vary sentence openings while preserving meaning and technical references: change the first to start with an action like "Handle redirects during SSR in your Rails controller (e.g., check auth before rendering)," the second to "Use <Navigate to=\"/path\" /> for client-side redirects (note: this is a no-op during SSR)," and the third to "Handle route errors with React Router's errorElement or an ErrorBoundary," keeping the parenthetical note about SSR behavior and the references to Rails controller, <Navigate to="/path" />, errorElement, and ErrorBoundary.
231-231: Optional: hyphenate compound adjective."Client-side only rendering" should technically be hyphenated as "Client-side-only rendering" when the compound adjective modifies "rendering":
-- Client-side only rendering (always forces server rendering) +- Client-side-only rendering (always forces server rendering)This is a minor grammar nit and doesn't affect clarity.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@docs/oss/core-concepts/render-functions.md` at line 231, Change the phrase "Client-side only rendering" to the hyphenated compound adjective "Client-side-only rendering" in the docs text so the compound properly modifies "rendering" (update the line that currently reads exactly "Client-side only rendering" in render-functions.md).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@docs/oss/core-concepts/render-functions.md`:
- Around line 166-167: Clarify the "error" key gotcha by explicitly noting that
any returned object containing the key "error" (not just "routeError") will be
treated as a server-render-hash result and therefore won't be rendered as a
React component; update the paragraph to add one short concrete example
reference (e.g., mention a component like MyComponent that returns { error:
'validation failed' } as props) and/or a one-sentence callout advising authors
to avoid using a top-level "error" field in render-returned objects (or rename
it) to prevent accidental server-render-hash handling — reference the terms
"error", "routeError", and "server-render-hash" so readers can map this guidance
to the existing detection logic.
- Around line 136-138: The three bullets all begin with "For" which is
repetitive; reword them to vary sentence openings while preserving meaning and
technical references: change the first to start with an action like "Handle
redirects during SSR in your Rails controller (e.g., check auth before
rendering)," the second to "Use <Navigate to=\"/path\" /> for client-side
redirects (note: this is a no-op during SSR)," and the third to "Handle route
errors with React Router's errorElement or an ErrorBoundary," keeping the
parenthetical note about SSR behavior and the references to Rails controller,
<Navigate to="/path" />, errorElement, and ErrorBoundary.
- Line 231: Change the phrase "Client-side only rendering" to the hyphenated
compound adjective "Client-side-only rendering" in the docs text so the compound
properly modifies "rendering" (update the line that currently reads exactly
"Client-side only rendering" in render-functions.md).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9994e46a-55d7-4438-9f60-73aeb23b195e
📒 Files selected for processing (2)
docs/oss/api-reference/view-helpers-api.mddocs/oss/core-concepts/render-functions.md
🚧 Files skipped from review as they are similar to previous changes (1)
- docs/oss/api-reference/view-helpers-api.md
| * - 0-1 params: Regular React component (function or class) | ||
| * - 2 params, or any function with `.renderFunction = true`: Render-Function — called with (props, railsContext), | ||
| * returns a React component, `{ renderedHtml }` object, or Promise (Pro Node renderer only) | ||
| * - 3 params: Renderer function — called with (props, railsContext, domNodeId), | ||
| * responsible for calling ReactDOM.render/hydrate directly (client-only) |
There was a problem hiding this comment.
The parameter detection description has two inaccuracies that could mislead readers trying to understand how the registry works.
1. "2 params" should be "2 or more params"
ComponentRegistry.ts line 28 uses isRenderFunction(component) which checks component.length >= 2 (not exactly 2). A function with 4+ parameters is also detected as a render function. This matters for edge cases where someone wraps or decorates a function.
2. Renderer functions are a subtype of render functions, not a separate category
The three-bullet list implies mutual exclusivity between "Render-Function" (2 params) and "Renderer function" (3 params). In reality:
const renderFunction = isRenderFunction(component); // true if length >= 2
const isRenderer = renderFunction && component.length === 3; // subset of render functionsA 3-param function satisfies both renderFunction === true AND isRenderer === true. The taxonomy is:
all registered components
└─ render functions (length >= 2, or .renderFunction = true)
└─ renderer functions (length === 3, subset of render functions)
Suggested correction:
| * - 0-1 params: Regular React component (function or class) | |
| * - 2 params, or any function with `.renderFunction = true`: Render-Function — called with (props, railsContext), | |
| * returns a React component, `{ renderedHtml }` object, or Promise (Pro Node renderer only) | |
| * - 3 params: Renderer function — called with (props, railsContext, domNodeId), | |
| * responsible for calling ReactDOM.render/hydrate directly (client-only) | |
| * Component detection: React on Rails distinguishes between component types by parameter count: | |
| * - 0–1 params: Regular React component (function or class) | |
| * - 2+ params, or any function with `.renderFunction = true`: Render-Function — called with (props, railsContext), | |
| * returns a React component, `{ renderedHtml }` object, or Promise (Pro Node renderer only) | |
| * - 3 params (a special case of Render-Function): Renderer function — called with (props, railsContext, domNodeId), | |
| * responsible for calling ReactDOM.render/hydrate directly (client-only) |
| | Render function → Promise (compatible return shape) | ✅ (Pro Node renderer) | ✅ (Pro Node renderer, must resolve to hash with `componentHtml`) | ✅ (Pro Node renderer, must resolve to React element) | | ||
| | Renderer function (3 params) | ✅ (client-only) | ❌ | ❌ | | ||
|
|
||
| > **Note:** ❌ marks an unsupported combination. Some mismatches raise a `ReactOnRails::Error` directly in Ruby (e.g., `react_component` with a hash result raises `"Use react_component_hash (not react_component)..."`, and `react_component_hash` with a non-hash result raises `"Render-Function... expected to return an Object"`). Others (renderer functions used in server rendering, Pro Node renderer mismatches) throw a JavaScript error that becomes `ReactOnRails::PrerenderError` when `raise_on_prerender_error` is enabled, or is embedded as an error comment in the HTML when it is not. Either way, these combinations are not silent data failures — they will surface as errors or visible error output. |
There was a problem hiding this comment.
The error messages quoted in this note don't quite match the source. The actual react_component error is:
Use react_component_hash (not react_component) to return a Hash to your ruby view code.
(helper.rb line 106)
And react_component_hash's error is:
Render-Function used by react_component_hash for #{component_name} is expected to return an Object.
(helper.rb line 172)
The note says "Render-Function... expected to return an Object" which is close but slightly paraphrased. Not a blocker, but worth tightening to the actual strings so readers can grep for them when debugging.
| | Render function → `{ renderedHtml: string }` | ✅ | ❌ | ❌ | | ||
| | Render function → `{ renderedHtml: ReactElement }` | ✅ (prerender only) | ❌ | ❌ | | ||
| | Render function → `{ renderedHtml: { componentHtml, ... } }` | ❌ | ✅ | ❌ | | ||
| | Render function → Promise (compatible return shape) | ✅ (Pro Node renderer) | ✅ (Pro Node renderer, must resolve to hash with `componentHtml`) | ✅ (Pro Node renderer, must resolve to React element) | |
There was a problem hiding this comment.
The async Promise row and the non-async "Return Type 6" example (render-functions.md lines 363–388) use inconsistent return structures that may confuse readers:
- Sync (Return Type 4):
{ renderedHtml: { componentHtml, title, ... } }— wrapped inrenderedHtml - Async / Pro Node renderer (Return Type 6):
{ componentHtml, title, ... }— flat hash, norenderedHtmlwrapper
The compatibility matrix note here says the Promise must "resolve to hash with componentHtml", which matches the flat-hash structure. But readers who switch from the sync to the async version will be confused about why the structure changes.
Consider adding a brief inline note to the async Promise row (or to section 6 example) explicitly calling out that the Pro Node renderer accepts the flat hash directly for backward compatibility, while the synchronous path requires the renderedHtml wrapper.
| import registerServerComponent from 'react-on-rails-pro/registerServerComponent/client'; | ||
|
|
||
| registerServerComponent({ rscPayloadGenerationUrlPath: 'rsc_payload/' }, 'ReactServerComponentPage'); | ||
| registerServerComponent('ReactServerComponentPage'); |
There was a problem hiding this comment.
Good fix — the old example was broken. The registerServerComponent client implementation signature is (...componentNames: string[]) (rest parameters), so passing an object as the first argument was silently wrong. The corrected form is correct.
One small follow-up: the JSDoc comment in client.tsx lines 41–42 still mentions options.rscPayloadGenerationUrlPath as a documented parameter, but the function no longer accepts it. If that option was removed, the JSDoc should be cleaned up too (separate from this PR, but worth tracking).
ReviewVerified all major behavioral claims against source code. The changes are well-researched and address real documentation gaps. A few issues to address before merging: Must Fix
The description implies "2 params → Render-Function" and "3 params → Renderer function" are mutually exclusive categories. They aren't:
This section will confuse anyone trying to understand why their 4-parameter function is or isn't detected correctly. SuggestionsAsync vs sync hash structure inconsistency — The sync return-type-4 example wraps the hash in Error message strings — The compatibility matrix footnote paraphrases two runtime error messages slightly. Worth tightening them to the verbatim strings so readers can grep for them when debugging (see inline comment on line 255 of Verified AccurateThe following claims were verified against source code and are correct:
Overall this is a solid improvement to some of the most confusing parts of the API documentation. |
…ages * origin/main: Fix initial page startup race for late-loading client bundles (#3151) chore: apply prettier formatting to tracked docs files (#3153) docs: comprehensive RSC API documentation and registration consolidation (#3140) Split rspec-package-tests into parallel generator/unit shards (#3134) fix: add concurrency groups to long-running CI workflows (#3133) refactor: add RenderRequest, JsCodeBuilder, and RenderingStrategy abstractions (#3094) fix: address deferred review items from PR #2849 (#3093) Add complimentary OSS license policy for React on Rails Pro (#3123) fix: centralize CI docs-only detection and add CLI flag validation (#3091) refactor: replace stub-throw + Object.assign with capability-based composition (#3096) Enhance address-review with parallel fixes, self-review, and Greptile verification (#3121) fix: Doctor no longer fails custom projects for missing bin/dev (#3117) fix: cap webpack <5.106.0 to prevent ExecJS SSR breakage (#3095) Add Rspack + RSC compatibility tests and documentation (#1828) (#3120) Add error scenarios hub and test pages (#2497) docs: document polyfill requirements for web-targeted server bundles (#3092) docs: RSC integration pitfalls from tutorial app (#3087) docs: fix render function/helper API documentation (#3088) Doctor: accept TS/TSX server bundle suffixes (#3111) feat: add CI guard requiring sidebar updates when adding docs (#3089)
Summary
Comprehensive documentation fixes for render functions, renderer functions, view helpers, and component registration APIs. Addresses documentation gaps and inaccuracies identified in #2911.
Key changes:
redirectLocation/routeErroras legacy (React Router v3/v4) with clear modern alternativesreact_component_hashbehavior: Document that it silently forcesprerender: truestream_react_componentbehavior: Document forcedprerender: trueandimmediate_hydration: true<Navigate>SSR behavior: Document that it's a no-op during SSR (renders null, redirect fires client-side only)'{}'with ExecJSerrorkey triggers server-render-hash processingclientPropsmerge: Document symbol/string key handling and edge casesregisterServerComponentgotcha: Add prominent callout about different signatures per bundle (server takes object, client takes strings)register()JSDoc: Rewrite with detection logic and complete return type documentationFiles changed:
docs/oss/core-concepts/render-functions.mddocs/oss/api-reference/view-helpers-api.mddocs/oss/api-reference/javascript-api.mdregister()JSDocdocs/oss/getting-started/using-react-on-rails.mddocs/oss/building-features/react-router.md<Navigate>SSR behavior sectiondocs/pro/react-server-components/inside-client-components.mdregisterServerComponentsignature gotchaCloses #2911
Test plan
🤖 Generated with Claude Code
Note
Low Risk
Docs-only updates clarifying helper/render-function contracts; low risk aside from potential confusion if guidance is inaccurate or links regress.
Overview
Updates OSS docs to correct and expand render-function and helper API guidance: rewrites
ReactOnRails.register()JSDoc to explain component detection (param count /.renderFunction) and supported return shapes, and clarifies when render-functions vs renderer functions are valid.Strengthens helper documentation by explicitly documenting forced behaviors and deprecations (e.g.,
react_component_hashandstream_react_componentforcingprerender: true,immediate_hydrationignored with warning), markingredirectLocation/routeErroras legacy with modern alternatives, and adding a compatibility matrix mapping return types toreact_component/react_component_hash/stream_react_component.Adds React Router SSR guidance for
<Navigate>being a client-only redirect, fixes getting-started examples to match the{ renderedHtml: { componentHtml, ... } }shape, and updates Pro RSC docs to highlightregisterServerComponent’s different server vs client signatures (with corrected client example).Reviewed by Cursor Bugbot for commit 489d433. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit