Skip to content

fix(layout): lay out render props of texts nested in a text - #3629

Draft
adarshsm wants to merge 1 commit into
diegomura:masterfrom
adarshsm:fix/3123-nested-dynamic-text
Draft

adarshsm wants to merge 1 commit into
diegomura:masterfrom
adarshsm:fix/3123-nested-dynamic-text

Conversation

@adarshsm

Copy link
Copy Markdown

Fixes #3123.

Problem

A render prop on a <Text> nested inside another <Text> never shows up in the PDF:

<Text>
  <Text render={() => 'This does not render'} />
</Text>

The same render prop works when it sits on the outer <Text> or on a <Text> in a <View>, which is why the issue reports it as a regression from 3.x.

Root cause

resolveDynamicNodes in resolvePagination.ts calls the render props and then runs the page through relayoutPage. It only clears lines (and the box height) on nodes that are dynamic themselves. The outer <Text> is static, so it keeps the lines that were measured on the first pass, when the nested text still had no children. resolveTextLayout skips nodes that already have lines, so the nested result never gets laid out and the text stays empty.

Fix

Reset lines and box.height for every <Text> that contains a dynamic node (shouldResolveDynamicNodes), not only for dynamic ones. Yoga then re-measures it with the resolved children.

Tests

  • New should lay out the result of a render prop on a nested text in packages/layout/tests/steps/resolvePagination.test.ts. It fails without the change (the text has no lines) and passes with it.
  • packages/layout/tests/{steps,text,node} pass (332 tests). The paginate/* and engineSelection suites can't load in my checkout (@react-pdf/paginate isn't linked), so they were not run.
  • I tested at the layout step with a hand-built node tree and did not render a PDF.
  • The opt-in paginate engine has its own renderDynamic, which looks like it has the same gap for a static outer text. I did not touch it because I couldn't run its tests here.

🤖 Generated with Claude Code

Pagination only reset the measured lines of a text that has a render
prop itself. A static <Text> whose nested <Text render={...}> produced
the content kept the lines measured before the render prop ran, so the
nested result was never laid out and nothing was drawn.

Reset the lines and height of any text that contains a dynamic
descendant.

Fixes diegomura#3123

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a34aec8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@react-pdf/layout Patch
@react-pdf/renderer Patch
@react-pdf/examples Patch
@react-pdf/math Patch
@react-pdf/mermaid Patch
@react-pdf/ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Nov 18, 2026

Copy link
Copy Markdown

@adarshsm is attempting to deploy a commit to the diegomura Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Nested <Text>'s with a render function don't render

1 participant