Skip to content

feat(core): add reverse prop to useTransition#2510

Merged
joshuaellis merged 2 commits into
nextfrom
feat/1794
May 22, 2026
Merged

feat(core): add reverse prop to useTransition#2510
joshuaellis merged 2 commits into
nextfrom
feat/1794

Conversation

@joshuaellis
Copy link
Copy Markdown
Member

@joshuaellis joshuaellis commented May 22, 2026

Closes #1794.

useTransition lost the v8-era transition.reverse() capability when the API became a render function. There is no built-in way today to make items trail forward on enter but backward on leave; the existing sort prop reverses display order, not trail delay order.

Approach

Adds reverse?: boolean to UseTransitionProps. When true, the order in which trail delays are assigned is flipped so the last visible item starts first and the trail accumulates backward across the remaining items. Toggle it with caller state (e.g. reverse: !open) to flip behaviour between enter and leave phases.

reverse is scoped to trail delay assignment only — render order is untouched, and sort remains the prop for display order. Two orthogonal concerns, two props. Backwards-compatible default false.

Items that don't actually transition this render (stable items with no update prop, items already mid-leave) stay outside the trail accumulator, so reverse only flips the items that are animating — same scope as trail itself.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
react-spring Error Error May 22, 2026 11:27am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 22, 2026

🦋 Changeset detected

Latest commit: b27ff7e

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

This PR includes changesets to release 13 packages
Name Type
@react-spring/core Minor
react-spring Patch
@react-spring/konva Minor
@react-spring/native Minor
@react-spring/three Minor
@react-spring/web Minor
@react-spring/zdog Minor
@react-spring/animated Minor
@react-spring/mock-raf Minor
@react-spring/parallax Minor
@react-spring/rafz Minor
@react-spring/shared Minor
@react-spring/types Minor

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

@joshuaellis joshuaellis merged commit cd13304 into next May 22, 2026
17 of 18 checks passed
@joshuaellis joshuaellis deleted the feat/1794 branch May 22, 2026 11:31
This was referenced May 22, 2026
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.

[regression] transition.reverse is currently not possible

1 participant