fix(react-pdf): draw a repeat container once in renderToBuffer - #366
Open
peter-cynomi wants to merge 1 commit into
Open
peter-cynomi wants to merge 1 commit into
peter-cynomi wants to merge 1 commit into
Conversation
The server walk used by `renderToBuffer`, `renderToStream` and `renderToFile` drew a repeat container once per item, so a container with its own content (a section title, a table header) was repeated for every item, and an empty repeat drew nothing. `@json-render/react` and react-pdf's provider `Renderer` draw the container once and put every item's children inside it. Draw the container once in the server walk too, with each item's children in a keyed fragment. This also removes React's missing `key` warning for repeats. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
|
@peter-cynomi is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
peter-cynomi
marked this pull request as ready for review
September 29, 2026 10:40
This branch has not been deployed
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.
Problem
The server walk behind
renderToBuffer,renderToStreamandrenderToFiledraws a repeat container once per item.@json-render/react, and react-pdf's own providerRenderer, draw the container once and put every item's children inside it.In the spec below, the outer section is repeated over
/domains, and each domain has a nestedTaskssection repeated over{ "$item": "tasks" }. The server walk draws a different structure from React:@json-render/react/ providerRendererrenderToBufferonmainAppendix B(outer repeat container title)Tasks(inner repeat container title)The effects:
keywarning, because the per-item containers are returned in an unkeyed fragment.Fix
The server walk now draws the container once, with each item's children in a keyed
React.Fragment. Item keys still userepeat.key, falling back to the index.Tests
packages/react-pdf/src/repeat-container.test.tsxruns a nested-repeat spec through both walkers and compares the order and count of the drawn lines. It also checks that an empty repeat draws its container once.Both walkers pass on this branch. On
main, therenderToBuffercases fail and the providerRenderercases pass.tsc --noEmitis clean and@json-render/react-pdfbuilds.Note
This touches the same repeat block in
render.tsxas #364, which filters repeat items by$iteminvisible. Whichever PR merges second will need a small rebase.🤖 Generated with Claude Code