Skip to content

Fix broken examples and code highlighting in ViewTransition and addTransitionType - #8737

Open
BlackHatMan wants to merge 1 commit into
reactjs:mainfrom
BlackHatMan:fix-view-transition-examples
Open

BlackHatMan wants to merge 1 commit into
reactjs:mainfrom
BlackHatMan:fix-view-transition-examples

Conversation

@BlackHatMan

Copy link
Copy Markdown
Contributor

Summary

Examples that don't work as written

  • ViewTransition → Troubleshooting → "two <ViewTransition name=%s> components": the fixed example destructures id in Item, but ItemList passes item={item}, so every item still gets name="item-undefined" and triggers the same error. Now passes id={item.id}.
  • addTransitionType → Usage: function Submit({action) { is a syntax error.
  • ViewTransition: the "Fast" checkbox used value={isFast}, which doesn't control a checkbox; changed to checked.
  • ViewTransition: in the wrapper-element snippet, key was on the inner <Component> instead of the element returned from map.

Highlighting that doesn't render

  • Six blocks used [3, 5] / [3] / [11] for line highlights. getHighlightLines in CodeBlock.tsx only matches {...}, so nothing was highlighted. Switched to braces.
    • In the "<div> above <ViewTransition>" Pitfall, the example was rewritten in [ViewTransition] Add docs for using with Activity #8320 and line 5 is now <Video>; the range is {3,7} (the <div> open/close), matching the similar Troubleshooting example.
    • In addTransitionType, [11] pointed at setShow(true); it now highlights addTransitionType(...) (line 10), which the section is about.
  • The first addTransitionType example had no language on the fence, so the [[...]] metadata was parsed as the language and the three CodeSteps referenced in the next paragraph never rendered. Step 2 was also missing its closing ].

Text

  • addTransitionType: <ViewTransition> has no layout prop.
  • ViewTransition → "Animating enter/exit with Activity": the text referred to a "sidebar", but the sandbox only renders a Counter.

Test plan

  • eslint and prettier pass on both files.
  • Compared server-rendered HTML before/after on the dev server: /reference/react/ViewTransition highlighted lines 3 → 11; /reference/react/addTransitionType inline CodeSteps 0 → 3, highlighted lines 0 → 1.

…ansitionType

The fixed example in "two <ViewTransition name=%s> components" still
passes item={item} while Item reads {id}, so every item is named
"item-undefined" and triggers the same error. The first addTransitionType
example has a syntax error ({action)) and a fence without a language, so
its CodeSteps never render.

Line highlights written as [3, 5] / [3] / [11] are ignored by
getHighlightLines, which only reads {...}; switch them to braces and
update ranges that no longer match the code.

Also use checked instead of value on the "Fast" checkbox, move key to
the outer element in the wrapper snippet, drop the nonexistent `layout`
prop from addTransitionType, and remove a "sidebar" reference from the
Activity example, which only has a counter.
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

This branch was successfully deployed

1 active deployment
Preview — 56c4d523 Deployed Nov 5, 2026 by vercel[bot]
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