-
Notifications
You must be signed in to change notification settings - Fork 50.4k
Support onGestureEnter/Exit/Share/Update events #35556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Comparing: 195fd22...d3e4329 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
This is like the onEnter/Exit/Share/Update events but for gestures. It allows manually controlling the animation using the passed timeline.
a0b5be4 to
d3e4329
Compare
| } | ||
| for (let i = 0; i < pendingEvents.length; i++) { | ||
| const viewTransitionEvent = pendingEvents[i]; | ||
| viewTransitionEvent(pendingTypes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This calls user code. Does it need to be wrapped in error handling? Didn't see where else that might be happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are similar to onRecoverableError. I don't think they're handled properly in the existing one in flushSpawnedWork is right neither.
The way these phases flush is that they keep mutable state so that they can pick up and flush remaining phases if one is missed. So if this errors, then it errors the view transition which then flushes the remaining work which flushes the previous work but it doesn't flush this again so it probably misses anything after this. That means that bugs in React code might not be properly handled.
However, to ensure that other callbacks are handled, these should probably be wrapped in try/catch for each callback so that they're independently handled. Same thing for onRecoverableError.
There's also a question of what the default priority and execution context should be for these.
Follow up to #35337. During a gesture, we always cancel the original animation and create a new one that we control. That's the one we need to add to the set that needs to be cancelled. Otherwise future gestures hang. An unfortunate consequence is that any custom ones that you start e.g. with #35556 or through other means aren't automatically cleaned up (in fact there's not even a clean up callback yet). This can lead these to freeze the whole UI afterwards. It would be really good to get this fixed in browsers instead so we can revert #35337.
…ts (#35564) Stacked on #35556 and #35559. Given that we don't automatically clean up all view transition animations since #35337 and browsers are buggy, it's important that you clean up any `Animation` started manually from the events. However, there was no clean up function for when the View Transition is forced to stop. This also makes it harder to clean up custom timers etc too. This lets you return a clean up function from all the events on `<ViewTransition>`.
…ts (#35564) Stacked on #35556 and #35559. Given that we don't automatically clean up all view transition animations since #35337 and browsers are buggy, it's important that you clean up any `Animation` started manually from the events. However, there was no clean up function for when the View Transition is forced to stop. This also makes it harder to clean up custom timers etc too. This lets you return a clean up function from all the events on `<ViewTransition>`. DiffTrain build for [c55ffb5](c55ffb5)
|
cc @eps1lon for DefinitelyTyped |
[diff facebook/react@41b3e9a6...d2908752](facebook/react@41b3e9a...d290875) <details> <summary>React upstream changes</summary> - facebook/react#35567 - facebook/react#35566 - facebook/react#35565 - facebook/react#35564 - facebook/react#35559 - facebook/react#35556 </details>
This is like the onEnter/Exit/Share/Update events but for gestures. It allows manually controlling the animation using the passed timeline.