@@ -11,7 +11,7 @@ import {
1111let suspendersCount = 0 ;
1212const observers = new Set < ( ) => void > ( ) ;
1313
14- let didCaptureNewState : ( value ?: PromiseLike < void > | void ) => void = null ;
14+ let didCaptureNewState : ( ( value ?: PromiseLike < void > | void ) => void ) | null = null ;
1515
1616function suspendViewTransitionCapture ( ) : void {
1717 suspendersCount ++ ;
@@ -56,7 +56,7 @@ export function AutoViewTransitionsOnClick({ match = "a[href]" }: AutoViewTransi
5656
5757 event . preventDefault ( ) ;
5858 event . stopPropagation ( ) ;
59- startViewTransition ( ( ) => startTransition ( ( ) => target . click ( ) ) ) ;
59+ startViewTransition ( ( ) => startTransition ( ( ) => ( target as HTMLElement ) . click ( ) ) ) ;
6060 }
6161
6262 globalThis . document . addEventListener ( "click" , captureClick , { capture : true } ) ;
@@ -86,7 +86,12 @@ interface ViewTransitionController {
8686
8787export function useViewTransition ( ) : { resumeViewTransitionCapture : ( ) => void ; transitionState : "idle" | "capturing-old" | "capturing-new" | "animating" | "skipped" ; startViewTransition : ( updateCallback ?: React . TransitionFunction ) => ( PromiseLike < void > | void ) ; suspendViewTransitionCapture : ( ) => void } {
8888 const [ transitionState , setTransitionState ] = useState < TransitionState > ( "idle" ) ;
89- useSyncExternalStore ( observers . add . bind ( observers ) , ( ) => suspendersCount , ( ) => 0 ) ;
89+ useSyncExternalStore ( ( onStoreChange ) => {
90+ observers . add ( onStoreChange ) ;
91+ return ( ) => {
92+ observers . delete ( onStoreChange ) ;
93+ }
94+ } , ( ) => suspendersCount , ( ) => 0 ) ;
9095
9196 useEffect ( ( ) => {
9297 if ( didCaptureNewState && ! suspendersCount ) {
0 commit comments