React Daily

Gesture Transitions Get a Polish Pass

Sebastian Markbåge delivered a comprehensive polish pass for React's gesture transition system with 6 merged PRs focused on cleanup callbacks, gesture events, and animation management. The work addresses browser bugs and adds essential cleanup mechanisms to prevent UI freezing, while introducing new gesture event handlers and improving the developer experience around view transitions.

Duration: PT3M56S

https://podlog.io/listen/react-daily-101f1abb/episode/gesture-transitions-get-a-polish-pass-65214782

Transcript

Hey there, React developers! Welcome back to another episode. I'm so glad you're here - grab your favorite morning drink because we've got some really exciting updates from the React team to dive into today.

So yesterday was one of those amazing days where you can just feel the momentum building around a feature. Sebastian Markbåge was absolutely on fire, delivering six thoughtful pull requests that are all about making React's gesture transition system more robust and developer-friendly. And honestly, the attention to detail here is just fantastic.

Let's start with the biggest story - Sebastian tackled a really important problem around cleanup callbacks. You know how when you're working with animations, especially custom ones, you sometimes end up in this tricky spot where things don't clean up properly when a transition gets interrupted? Well, that's exactly what PR 35564 solves. Now you can return cleanup functions from all your ViewTransition events, which means no more worrying about animations hanging around and potentially freezing your UI. It's one of those changes that just makes sense the moment you hear about it.

But that's not all - we also got support for a whole new set of gesture events. PR 35556 introduces onGestureEnter, onGestureExit, onGestureShare, and onGestureUpdate events. These work just like the regular transition events you might already be familiar with, but they're specifically designed for gesture interactions. The cool part is they give you access to the timeline, so you can manually control your animations with really fine-grained precision.

Now, here's where it gets really interesting from a technical perspective. Sebastian also fixed an issue with useInsertionEffect in PR 35565. If you've ever used useInsertionEffect to inject styles that affect layout - maybe for a CSS-in-JS library or dynamic theming - you'll appreciate this one. The problem was that during gesture snapshots, these effects weren't firing, which could lead to missing styles in your transitions. Now React temporarily mounts these effects just long enough to get the snapshot right, then unmounts them before the animation starts. It's like a perfectly choreographed dance!

There were also some important bug fixes around animation cleanup. You know how browsers can be a bit... quirky sometimes with web animations? Well, Sebastian tackled a specific issue where gesture animations weren't being properly added to the cleanup set, which could cause future gestures to hang. Plus there was a Firefox-specific fix for when custom timelines are used with their ScrollTimeline polyfill.

And here's a nice quality-of-life improvement - they removed a warning that was firing when cloning the root during gesture transitions. It was one of those warnings that wasn't really actionable yet since the optimization it was hinting at isn't implemented. Instead, they added more targeted warnings for genuinely problematic cases like iframes and video elements that really shouldn't be cloned.

What I love about this series of changes is how they show the React team's commitment to not just shipping features, but making sure they work reliably in the real world. These aren't flashy new APIs - they're the kind of thoughtful improvements that make the difference between a feature that's cool in demos and one that you can actually ship to production with confidence.

Today's focus is really about stability and developer experience. If you've been experimenting with React's transition features, now's a great time to revisit any custom animations you've built and take advantage of these new cleanup patterns. And if you haven't started exploring gestures and view transitions yet, this polish pass makes it a much more solid foundation to build on.

That's a wrap for today's episode! The React team continues to show us what thoughtful, iterative development looks like. Keep building amazing things, and I'll catch you tomorrow with whatever exciting updates come our way. Until then, happy coding!